I'm trying to call the variable r from another class, but I'm having trouble making it.
Code:
public class Circle {
final double PI = 3.14159;
CircleTester temp = new CircleTester();
double radius = temp.gettemprad(); //this is where i was gonna call a method but I was having trouble making one in my other class
Circle(double newradius){
newradius = radius;
}
Circle(){
radius = 0.0;
}
void setRadius(double inputradius){
radius = inputradius;
}
double getRadius(){
return radius;
}
double getArea(){
return PI * radius * radius;
}
double getDiameter(){
return radius * 2;
}
double getCircumference(){
return 2 * PI * radius;
}
}
Code:
import java.util.Scanner;
public class CircleTester {
public static void main(String [] args){
double r;
Circle c = new Circle();
Scanner scan = new Scanner(System.in);
System.out.println("What is the radius of the circle");
r = scan.nextDouble();
//after I got r to the other class i was going to call the methods below
System.out.println("The circle's area is "+c.getArea());
System.out.println("The circle's diameter is "+c.getDiameter());
System.out.println("The circumference is "+c.getCircumference());
}
}
Basically I want the user input (r) to go to the other class so I can get different measurements from it and then return those values back to the original class using System.out.print. Thanks.