要求用户输入三个数,将其中最大的数找出来

来源:互联网 发布:sas数据分析大赛 编辑:程序博客网 时间:2024/05/01 08:50
import javax.swing.JOptionPane;
public class Mytest {


public static void main(String[] args) {
String x=JOptionPane.showInputDialog(null,"请输入第一个数:");
int a=Integer.parseInt(x);
String y=JOptionPane.showInputDialog(null,"请输入第二个数:");
int b=Integer.parseInt(y);
String z=JOptionPane.showInputDialog(null,"请输入第三个数:");
int c=Integer.parseInt(z);
if(a>b && a>c){
JOptionPane.showMessageDialog(null, "最大的数是:"+a);
}
else if(b>a && b>c){
JOptionPane.showMessageDialog(null, "最大的数是:"+b);
}
else if(c>a && c>b){
JOptionPane.showMessageDialog(null, "最大的数是:"+c);
}
else{
JOptionPane.showMessageDialog(null, "你输入的数有重复,请重新输入!");
}
}

}

0 0
原创粉丝点击