package jhg;
import java.util.Scanner;
public class AdditionQuiz {
public static void main(String[] args) {
int number1=(int)(System.currentTimeMillis() % 10);
int number2=(int)(System.currentTimeMillis() * 7 % 10);
//create a Scanner
Scanner input=new Scanner(System.in);
System.out.print(
"What is"+number1+"+"+number2+"?");
int answer =input.nextInt();
System.out.println(
number1 + "+" + number2 + "=" + answer + "is+" +
(number1+number2==answer));
input.close();
}
}
结果
参考同学的
package jhg;
import javax.swing.*;
public class TouchType{
public static void main(String args[]){
int num;
String s=(String)JOptionPane.showInputDialog(null,"输入字数","打字成绩判断",
JOptionPane.PLAIN_MESSAGE,null,null,null);
num=Integer.parseInt(s);
{
if(num>=15&&num<=30)
System.out.println("及格");
if(num>30)
System.out.println("优秀");
if(num<15)
System.out.println("不合格");
}
}
}
运行结果