/*
* Copyright (c) 2015,烟台大学计算机学院
* All right reserved.
* 文件名:test.java
* 作者:柴银平
* 完成时间:2015年9月22日
* 版本号:v1.0
*
* 问题描述:给出两个一百以内的数做加法,输入答案,然后输出正误判断。
*
* 程序输入:两个数的和。
* 程序输出: 输出正误判断,错误的给出正确答案。
*/
import java.util.Scanner;
public class test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int num = (int) (System.currentTimeMillis() % 100);
Scanner in = new Scanner(System.in);
int num1 = (int) (System.currentTimeMillis() % 100);
System.out.println("What is " + num + "+" + num1 + " ?");
System.out.println("Please input the answer:");
int ans = in.nextInt();
if (num + num1 == ans)
{
System.out.println(num + "+" + num1 + "=" + ans + " is "
+ (num + num1 == ans));
}
else
System.out.println("Your answer is wrong!The right answer is "+(num+num1));
//
}
}
测试图示: