import java.util.Scanner;

 public class Solution
 {
     public static void main(String[] args)
     {
         Scanner input = new Scanner(System.in);
         int correctCount = 0;
         int answer = 0;
         int number1;
         int number2;

         long startTime = System.currentTimeMillis();

         for(int i = 0; i < 10; i++)
         {
             number1 = (int)(Math.random() * 15);
             number2 = (int)(Math.random() * 15);
             System.out.print(number1 + " + " + number2 + " = ? ");
             answer = input.nextInt();
             if(answer == number1 + number2)
                 correctCount++;
         }

         input.close();

         long endTime = System.currentTimeMillis();
         long usedTime = (endTime - startTime) / 1000;

         System.out.println("You have " + correctCount + " answers");
         System.out.println("Used time: " + usedTime);
     }
 }

HW4.2的更多相关文章

  1. HW4.46

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  2. HW4.45

    public class Solution { public static void main(String[] args) { int count = 0; for(int i = 1; i < ...

  3. HW4.44

    public class Solution { public static void main(String[] args) { double randX; double randY; int hit ...

  4. HW4.43

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  5. HW4.42

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  6. HW4.41

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  7. HW4.40

    public class Solution { public static void main(String[] args) { long positiveSide = 0; long negativ ...

  8. HW4.39

    public class Solution { public static void main(String[] args) { double sum; double baseSalary = 500 ...

  9. HW4.38

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  10. HW4.37

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

随机推荐

  1. ctrl+c关闭多线程python程序

    项目中经常需要用到多线程,如果一个python程序用了多线程,当子线程没有结束时,用ctrl+c是关闭不了主线程的,这时候就只能用kill命令杀掉,这样会很麻烦. 所以探讨了下怎么ctrl+C关闭多线 ...

  2. 什么是UI控件

    凡是带有Widget参数的组件都是控件.

  3. Oracle学习笔记1: 表与约束

    1. 登录SQL Plus: 系统用户有哪些: 1. sys,system权限比较高的用户: 2. sysman操作企业管理器使用的. 1.2 的密码是安装oracle是设置的. 3. scott用户 ...

  4. Windows Phone 8 开发环境搭建

    原地址:http://blog.csdn.net/md521/article/details/11015139 Windows Phone 8将采用与Windows 8相同的NT内核,这就意味着WP8 ...

  5. HDU Traffic Real Time Query System

    题目大意是:对于(n, m)的图,给定边a, b查询从a到b要经过的割点的最少数目. 先tarjan算法求双连通然后缩点,即对于每个割点将周围的每个双连通看成一个点与之相连.然后求解LCA即可,距离d ...

  6. cocos-html5 JS 写法基础 语言核心

    转载:http://blog.csdn.net/leasystu/article/details/18735797 cocos2dx 3.0 js继承:John Resiq的继承写法解析 CCClas ...

  7. 还是编码 汉字(GB2312和GBK)的ASCII码对照表

    GB2312和GBK每一个汉字由2个字节组成,这2个字节的ASCII码大小分别是:gb2312: high8 = 0xa1-->0xfe (161 - 254)low8 = 0xa1--> ...

  8. java路径中的空格问题(转)

    java路径中的空格问题 1. URLTest.class.getResource("/").getPath(); URLTest.class.getResource(" ...

  9. ruby 线程学习

    i=1 Thread.start{ while true print "Thread 1 \n" i+=1 if i==5 then Thread.kill Thread.curr ...

  10. 微小说《tree》

    自己一直是一个矛盾纠结的人,计算机专业,却喜欢画画,偶尔会写些短文,寓言,或者酸酸的情诗.. 废话不多说,各位看官有兴趣便随意看看,若有些于共鸣,便共勉之. 正文 两株幼苗从土壤中破土而出,一颗天生强 ...