我对 Java 非常陌生(即 AP 计算机科学 A 第 2 周)。我们必须使用 JOptionPane 来制作用于数学运算的消息框。我的代码在学校很好,但我不得不重新格式化它,因为我把它保存在 Facebook 上(没有其他选择)。现在,我在所有 JOptionPane 行上都收到错误消息,上面写着“此行有多个标记”和“令牌上的语法错误”。我该如何解决。这是代码(请只修复我的要求,仅此而已,我知道代码可能很奇怪)
import javax.swing.JOptionPane;
public class OptioPane {
public static void main(String[] args) {
}
String a = JOptionPane.showInputDialog("Enter an integer");
String b = JOptionPane.showInputDialog("Input another");
int x = Integer.parseInt(a);
int y = Integer.parseInt(b);
JOptionPane.showMessageDiaglog(null, "The numbers added together is " +(x+y));
String c = JOptionPane.showInputDialog("Enter an integer");
String d = JOptionPane.showInputDialog("Input another");
int f = Integer.parseInt(c);
int g = Integer.parseInt(d);
JOptionPane.showMessageDialog(null, "The second number subtracted from the first number is " +(f-g));
String s = JOptionPane.showInputDialog("Enter an integer");
String r = JOptionPane.showInputDialog("Input another");
int w = Integer.parseInt(a);
int q = Integer.parseInt(b);
JOptionPane.showMessageDialog(null, "The numbers multiplied together is " +(w*q));
String k = JOptionPane.showInputDialog("Enter an integer");
String j = JOptionPane.showInputDialog("Input another");
int n = Integer.parseInt(a);
int m = Integer.parseInt(b);
JOptionPane.showMessageDialog(null, "The first number divided by the second number is " +(n/m));
String fir = JOptionPane.showInputDialog("Enter an integer");
String tir = JOptionPane.showInputDialog("Input another");
int ah = Integer.parseInt(a);
int bh = Integer.parseInt(b);
JOptionPane.showMessageDialog(null, "The first number modulated by the second number is " +(ah*bh));
}