错误太多,no2,no3两行前面有中文空格,去掉和换成英文空格。
max,min可能没被初始化,定义时赋值为0,
hsowMessageDialog方法有问题,缺少标题参数。这是我改过的,你再试试:import javax.swing.JOptionPane; public class Q26{
public static void main( String args[])
{
String no1,no2,no3,no4,no5;
int max=0,min=0,c1,c2,c3,c4,c5;
no1 = JOptionPane.showInputDialog("请输入第一个整数");
no2=JOptionPane.showInputDialog("请输入第二个整数");
no3 = JOptionPane.showInputDialog("请输入第三个整数");
no4 = JOptionPane.showInputDialog("请输入第四个整数");
no5 = JOptionPane.showInputDialog("请输入第五个整数");
c1 = Integer.parseInt(no1);
c2 = Integer.parseInt(no2);
c3 = Integer.parseInt(no3);
c4 = Integer.parseInt(no4);
c5 = Integer.parseInt(no5);
if (c1>c2)
max = c1;
if (c1<c2)
max = c2;
if (max<c3)
max = c3;
if (max<c4)
max = c4;
if (max<c5)
max = c5;
if (c1<c2)
min = c1;
if (min>c3)
min = c3;
if (min>c4)
min = c4;
if (min>c5)
min = c5;
String msg = "MAX="+max +"MIN="+min;
JOptionPane.showMessageDialog(null,msg,"title",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
max,min可能没被初始化,定义时赋值为0,
hsowMessageDialog方法有问题,缺少标题参数。这是我改过的,你再试试:import javax.swing.JOptionPane; public class Q26{
public static void main( String args[])
{
String no1,no2,no3,no4,no5;
int max=0,min=0,c1,c2,c3,c4,c5;
no1 = JOptionPane.showInputDialog("请输入第一个整数");
no2=JOptionPane.showInputDialog("请输入第二个整数");
no3 = JOptionPane.showInputDialog("请输入第三个整数");
no4 = JOptionPane.showInputDialog("请输入第四个整数");
no5 = JOptionPane.showInputDialog("请输入第五个整数");
c1 = Integer.parseInt(no1);
c2 = Integer.parseInt(no2);
c3 = Integer.parseInt(no3);
c4 = Integer.parseInt(no4);
c5 = Integer.parseInt(no5);
if (c1>c2)
max = c1;
if (c1<c2)
max = c2;
if (max<c3)
max = c3;
if (max<c4)
max = c4;
if (max<c5)
max = c5;
if (c1<c2)
min = c1;
if (min>c3)
min = c3;
if (min>c4)
min = c4;
if (min>c5)
min = c5;
String msg = "MAX="+max +"MIN="+min;
JOptionPane.showMessageDialog(null,msg,"title",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货