//My objective of the program is using scanner class to get the input from the user and use a dialog box(JOptionPane) for output. When I compile the file I was able to enter the input from the scanner class, but I did not see the dialog box for the output using JOptionpane?
PLEASE HELP!!!
import javax.swing.*;
import java.util.Scanner;
import static java.lang.Math.*;
public class Volume
{
public static void main (String[] args)
{
//Declaring Variables
double radius;
double height;
//public static double length;
double sphere;
double cylinder = 0;
//Initialize Scanner to read from user
Scanner input = new Scanner(System.in);
//Read the radius from the user
System.out.print("Enter a radius in meters : ");
radius = input.nextDouble();
//Compute the volume of sphere
sphere = 4/3*PI*Math.pow(radius, 3);
//Compute the height of a cylinder
height = cylinder/(PI*radius*radius);
//Display their averages in the Dialog Box
JOptionPane.showMessageDialog(null, "The volume of the sphere is: " + sphere +
"\n The height of a cylinder: " + height, "Calculations",JOptionPane.INFORMATION_MESSAGE);
}
}