Not getting the correct output
import java.util*;
public class Ch3_Prexercise2
{
static Scanner console = new Scanner(System.in);
public static void main(String[] args)
{
int height;
int radius;
double height;
double radius;
System.out.print(Enter the height of the cylinder: ");
radius = console.nextDouble();
System.out.println();
System.out.print("Volume of the cylinder = "
+ PI * Math.pow(radius, 2.0 + height);
System.out.print("Enter the radius of the base of the "
+ " cylinder: ");
height = console.nextDouble();
System.out.println();
System.out.println("Surface area: "
+ (2 * PI * Math.pow(radius, 2.0))
+ (2 * PI * radius * height));
static final double PI = 3.14159;
}
}
Re: Not getting the correct output
Consider
- Telling us what this program is supposed to do. We can't read minds and so have no idea what the "correct output" might be.
- Telling us what this program currently does. Does it compile or are there compilation errors? Does it throw exceptions? If you receive any errors or exceptions, then post them.
- Surround your code with [code=java] [/code] tags as per the forum FAQ. This helps your posted code retain its formatting so that it might be readable.
Re: Not getting the correct output
sorry.....
the program needs to prompt the user to input the height and the radius of the base of a cylinder and output the volume and surface area of the cylinder. Also modify the relevant output statements to format the output to two decimal places:o
Re: Not getting the correct output
And how is it not currently working? What is wrong with the above code? And again, can you edit your first post and place [code=java] [/code] tags around it:
[code=java]
//... your code goes here
[/code]