import javax.swing.*;
public class Test
{
int num1,num2;
while(true)//illegal start of type
{
num1=Integer.parseInt(JOptionPane.showInputDialog("Enter a number please:"));
num2=Integer.parseInt(JOptionPane.showConfirmDialog("Enter another number please:"));
if(num2!=0&&num1/num2>=10)
System.out.println(num1/num2);
else
System.out.print("The result is less than 10!");
}
}//<identifier> expected
----------------解决方案--------------------------------------------------------
添加了main()函数,又出现了一个错误:
import javax.swing.*;
public class Test
{
public static void main(String args[])
{
int num1,num2;
while(true)
{
num1=Integer.parseInt(JOptionPane.showInputDialog("Enter a number please:"));
num2=Integer.parseInt(JOptionPane.showConfirmDialog("Enter another number please:"));//cannot result symbol method showConfirmDialog(java.lang.String)
if(num2!=0&&num1/num2>=10)
System.out.println(num1/num2);
else
System.out.print("The result is less than 10!");
}
}
}
这是什么错误呀?谢谢!!
----------------解决方案--------------------------------------------------------
晕死,我知道哪里错了。
----------------解决方案--------------------------------------------------------
怎么看都象死循环
----------------解决方案--------------------------------------------------------
看看这样行不行?
import javax.swing.*;
public class Test
{
public static void main(String args[])
{
int num1,num2;
boolean f;
while(f==true)
{
num1=Integer.parseInt(JOptionPane.showInputDialog("Enter a number please:"));
num2=Integer.parseInt(JOptionPane.showConfirmDialog("Enter another number please:"));//cannot result symbol method showConfirmDialog(java.lang.String)
if(num2!=0 && num1/num2>=10)
{f=true
System.out.println(num1/num2);
}
else
System.out.print("The result is less than 10!");
}
}
}
----------------解决方案--------------------------------------------------------
import javax.swing.*;
public class test
{
public static void main(String args[])
{
int num1,num2;
num1=Integer.parseInt(JOptionPane.showInputDialog("Enter a number please:"));
num2=Integer.parseInt(JOptionPane.showInputDialog("Enter another number please:"));
if(num2!=0&&num1/num2>=10)
System.out.println(num1/num2);
else
System.out.print("The result is less than 10!");
}
}
showConfirmDialog不能那样用呀……所以会错,我不想无限的输入数字……所以我把while去掉了
----------------解决方案--------------------------------------------------------