据我所知,我做得对(显然不是)我试图将字符串更改为双打,因为我无法从 JPane 获得双打。它给了我一个对象未初始化的错误。我如何解决它?
import javax.swing.JOptionPane;
public class jwindows {
public static void main (String args[]) {
double a, b, c;
double sum = a + b + c;
double product = a * b * c ;
double avarge = a * b * c / 3;
String stringA = JOptionPane.showInputDialog
(null, "Please enter first number");
a = Double.parseDouble(stringA);
String stringB = JOptionPane.showInputDialog
(null, "Please enter second number: ");
b = Double.parseDouble(stringB);
String stringC = JOptionPane.showInputDialog
(null, "Please enter third number: ");
c = Double.parseDouble(stringC);
JOptionPane.showInternalMessageDialog
(null, "The sum of the 3 numbers is " + sum);
JOptionPane.showInternalMessageDialog
(null, "The avarge of the 3 numbers is " + avarge);
JOptionPane.showInternalMessageDialog
(null, "The sum of the 3 numbers is " + product);
}
}