I'm writing a program that calculates the volume and area of sphere, but I get errors when I'm trying to use showMessageDialog and showInputDialog, why?
import javax.swing.JOptionPane.*;
public class Main {
public static void main(String[] arg) {
String s = showInputDialog(null, "What is the radius of the sphere?");
double radius = Double.parseDouble(s);
double volume = (4*3.14*radius*radius*radius)/3;
double area = 4*3.14*radius*radius;
showMessageDialog(null, "The volume is " + volume + " and the area is " + area);
}
}
Error:
Main.java:5: cannot find symbol
symbol : method showInputDialog(<nulltype>,java.lang.String)
location: class Main
String s = showInputDialog(null, "What is the radius of the sphere?");
Main.java:9: cannot find symbol
symbol : method showMessageDialog(<nulltype>,java.lang.String)
location: class Main
showMessageDialog(null, "The volume is " + volume + " and the area is " + area);
2 errors
BUILD FAILED (total time: 0 seconds)