Receive data from an array
I've only been programming in Java for three weeks, so take it easy on me.
I have created an array inside of a class. I want to receive the values of that array from within another class. The programs compile, but the answers are wrong.
public class Circle
private double radius; //instance variable
* Constructor for objects of class Circle
radius = 0; //initialise instance variables
public Circle(double r)
radius = r;
public void SetRadius(double r)
//modifying method allowing you to assign a new value to the variable
radius = r;
public double GetProperties()
double Properties = new double;
Properties = 2 * radius; //Diameter
Properties = 2 * Math.PI * radius; //Circumference
Properties = Math.PI * Math.pow(radius, 2); //Area
When I input 1 for my radius, here is my output:
public class CircleTester
public static void main (Stringargs)
Scanner keyboard = new Scanner(System.in);
System.out.print("Please enter the radius: ");
Circle circle = new Circle(keyboard.nextDouble());
//Below, shouldn't I be declaring which position in the array I want
// to access from?
System.out.println("Diameter: " + circle.GetProperties());
System.out.println("Circumference: " + circle.GetProperties());
System.out.println("Area: " + circle.GetProperties());
What am I doing wrong?