import javax.swing.JOptionPane;
public class SubtractionTutor
{public static void main(String[] args)
{
int num1=(int)(Math.random()*10);//产生两个随机数
int num2=(int)(Math.random()*10);
if(num1<num2)
{int temp=num1;
num1=num2;
num2=temp;}
String answerString=JOptionPane.showInputDialog
("what is"+num1+"-"+num2+"?");
int answer=Integer.parseInt(answerString);
String replyString;
if(num1-num2==answer)
replyString="you are correct!";
else
replyString="your answer is wrong.\n"+num1+"-"+num2+"should be"+(num1-num2);
JOptionPane.showMessageDialog(null,replyString);
}
}
public class SubtractionTutor
{public static void main(String[] args)
{
int num1=(int)(Math.random()*10);//产生两个随机数
int num2=(int)(Math.random()*10);
if(num1<num2)
{int temp=num1;
num1=num2;
num2=temp;}
String answerString=JOptionPane.showInputDialog
("what is"+num1+"-"+num2+"?");
int answer=Integer.parseInt(answerString);
String replyString;
if(num1-num2==answer)
replyString="you are correct!";
else
replyString="your answer is wrong.\n"+num1+"-"+num2+"should be"+(num1-num2);
JOptionPane.showMessageDialog(null,replyString);
}
}