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. centos系统python升级2.7.3

    首先下载源tar包 可利用linux自带下载工具wget下载,如下所示: wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz 下载 ...

  2. jquery 验证插件 validate

    1)required:true 必输字段(2)remote:"check.php" 使用ajax方法调用check.php验证输入值(3)email:true 必须输入正确格式的电 ...

  3. LCD显示方向

    一.ILI9341内存到显示地址的映射 本文只讨论“正常显示”,不讨论“垂直滚动显示”模式. 可以看到物理内存被两个指针访问,行指针和列指针,行指针范围从000h到013Fh,列指针范围为0000h到 ...

  4. Git权威指南 读笔(3)

    第九章 恢复进度: $ git stash list 显示存储的工作进度列表. $ git stash 保存当前的工作进度,分别对暂存区和工作区的状态进行保存. $ git stash pop [-- ...

  5. sencha touch mvc

    controller: Ext.define('MyApp2.controller.MyController1', { extend: 'Ext.app.Controller', config: { ...

  6. ee_15_mvc_db_page----demo---bai

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"% ...

  7. SQL语句中使用条件逻辑

    select name, sal, case when sal >= 4000 then 'Good' when sal <= 2000 then 'Bad' else 'Ok' end ...

  8. CFNetwork学习总结

  9. pgrep 查询进程的工具

    pgrep 1:简介 pgrep 是通过程序的名字来查询进程的工具,一般是用来判断程序是否正在运行.在服务器的配置和管理中,这个工具常被应用,简单明了: 1:用法 #pgrep 参数选项 程序名 常用 ...

  10. RadioGroup 的 RadioButton 选择改变字体颜色和背景颜色

    RadioGroup <RadioGroup android:id="@+id/client_charge_radiogroup" android:layout_width= ...