I am making a program that gives the area of a specific shape. I have:
If the user input anything but 1 or 2, I want it to say try again and start just that step over. How would I do that? Thanks.
if(z == 1)
{
System.out.println("Enter the radius of the sphere: ");
int y = scan.nextInt();
System.out.println("The volume of the Sphere is: ");
System.out.println((4/3) * pi * Math.pow(y,3));
}
else if(z == 2)
{
System.out.println("Enter the length of one side of the cube: ");
int x = scan.nextInt();
System.out.println("The volume of the Cube is: ");
System.out.println(Math.pow(x,3));
}
If the user input anything but 1 or 2, I want it to say try again and start just that step over. How would I do that? Thanks.