本文介绍了需要一些帮助,请使用java asssignment。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要写一个接受两个数字的程序,如果第一个数字大于第二个数字,它应该使用JOptionPane打印第一个数字更大。
我得到一个错误我不能调试,下面是错误....
I am to write a program that accept two numbers, if first number is greater than second number, it should print "First number is larger", using JOptionPane.
Am getting one error I cant debug, below is the error....
Numbas.java:17: error: cannot find symbol
JOptionPane.showMessageDialog(null, Result, "Comparism Results", JOption
Pane.InformationMessage);
^
symbol: variable InformationMessage
location: class JOptionPane
1 error
我尝试过:
What I have tried:
import javax.swing.JOptionPane;
public class Numbas{
public static void main (String[] args){
String FirstNum, SecondNum, Result;
int Number1, Number2;
FirstNum = JOptionPane.showInputDialog("Enter the first number please");
SecondNum = JOptionPane.showInputDialog("Please enter the second number");
Number1 = Integer.parseInt(FirstNum);
Number2 = Integer.parseInt(SecondNum);
Result = " ";
if (Number1 > Number2)
Result = Number1 + "is larger";
if (Number2 > Number1)
Result = Number2 + "is larger";
if (Number1 == Number2)
Result = "The numbers are equal";
JOptionPane.showMessageDialog(null, Result, "Comparism Results", JOptionPane.InformationMessage);
System.exit(0);
}
}
推荐答案
这篇关于需要一些帮助,请使用java asssignment。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!