统计信息

  • 访问数:14069
  • 博客数:143
  • 建立时间:2008-01-05
  • 更新时间:2008-10-15
我叫王超然,是一名电脑爱好者,现在在新加坡留学上高一.我立志成为一名电脑人才,愿意在这里与大家一同分享我玩转电脑的心得.O-level华文考了A-One哈哈!

P2Q5

2008-01-21 17:29:21

天气: 晴朗 心情: 高兴

/*P2Q5
 *Name:Wang Chaoran
 * Description:5 (Addition for three numbers)
The program in Listing 3.3 generates two integers and prompts the
user to enter the addition of these two integers. Revise the program
to generate three single-digit integers and prompt the user to enter
the addition of these three integers. 
 1  import java.util.Scanner;
 2
 3  public class AdditionTutor {
 4    public static void main(String[] args) {
 5      int number1 = (int)(System.currentTimeMillis() % 10);
 6      int number2 = (int)(System.currentTimeMillis() * 7 % 10);
 7     
 8      Scanner scan = new Scanner(System.in);
 9
10      System.out.print("What is " + number1 + " + " + number2 + "?");
11      int answer = scan.nextInt();
12
13      System.out.println(number1 + " + " + number2 + " = " + answer + " is " +
14        (number1 + number2 == answer));
15    }
16  }

 */
import java.util.Scanner;
public class P2Q5
{
  public static void main(String[] args)
  {
    int number1 = (int)(System.currentTimeMillis()%10);
    int number2 = (int)(System.currentTimeMillis()*7%10);
    int number3 = (int)(System.currentTimeMillis()*9%10);
    Scanner scan = new Scanner(System.in);
    System.out.print("What is " + number1 + " + " + number2 +" + "+number3+ "?");
      int answer = scan.nextInt();

      System.out.println(number1 + " + " + number2 + " = " + answer + " is " +
        (number1 + number2 +number3 == answer));
  }
}
     


加入收藏 编辑 审核

TAG: computing

我来说两句

OPEN

Powered by X-Space 1.2 © 2001-2006 Comsenz Technology Ltd