I'm writing some code for school (a test class and a primary class), and when I create a test class, the methods I call from the primary class are "undefined for type CylinderTest". When I try to run the program anyway, Eclipse can't even find the main class.
I've looked over so many stack overflow questions for the answer. I've had a similar problem here, but that doesn't fix my current problem. I've also tried (on my own) importing java.util.Scanner into the problem class, but that didn't work, either
File #1
package CirclePackage;
import java.util.Scanner;
public class Cylinder {
public static double askForRadius() {
System.out.println("What would you like the radius of the cylinder to be?");
Scanner in = new Scanner(System.in);
double r = in.nextDouble();
in.close();
return r;
}
public static double askForheight() {
System.out.println("What would you like the height of the cylinder to be?");
Scanner in = new Scanner(System.in);
double h = in.nextDouble();
in.close();
return h;
}
public static double getVolume(double radius, double height) {
double area = Math.PI*radius*radius*height;
return area;
}
}
File #2:
package CirclePackage;
public class CylinderTest {
static void main(String[] args) {
double r = askForRadius(); //<--------------Errors appear HERE,
double h = askForheight(); //<----------------------------HERE,
double result = getVolume(r, h); //<------------------and HERE.
System.out.println("The Volume of the cylinder is: " + result);
}
}
This program is supposed to calculate the volume of a cylinder based on user inputs for the cylinder's radius and height. It does not.