HW4.2


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的更多相关文章
- HW4.46
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW4.45
public class Solution { public static void main(String[] args) { int count = 0; for(int i = 1; i < ...
- HW4.44
public class Solution { public static void main(String[] args) { double randX; double randY; int hit ...
- HW4.43
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW4.42
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW4.41
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW4.40
public class Solution { public static void main(String[] args) { long positiveSide = 0; long negativ ...
- HW4.39
public class Solution { public static void main(String[] args) { double sum; double baseSalary = 500 ...
- HW4.38
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW4.37
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
随机推荐
- python 从SocketServer到 WSGIServer 源码分析、
python 下有个wsgi的封装库.wsgiref. WSGI 指的是 Web服务器网关接口(Python Web Server Gateway Interface) django的runserve ...
- TIBCO ActiveMatrix BPM 生成daa包脚本
Ant 配置: <?xml version="1.0" encoding="UTF-8" ?> <project name="pro ...
- 基于C#的SolidWorks插件开发(2)--创建插件
在项目工程中可以看到SwAddin.cs文件.这个文件是插件的核心文件,包括插件的名称,注册表项,菜单,以及菜单的回调函数都在该文件中实现. 1.修改插件的名称和描述 Guid为插件生成后注册到注册表 ...
- qt 5 界面美化
大家都知道,用UI做起界面来非常方便,但是如果我们不熟练他的操作的话,做起来也会有不少布局的麻烦, 所以,我打算写一篇文章来记录自己参考大牛用代码写界面的文章,感谢百度,感谢各位QT大牛的帮助. 所谓 ...
- VS2015下的Android开发系列01——开发环境配置及注意事项
概述 VS自2015把Xamarin集成进去后搞Android开发就爽了,不过这安装VS2015完成的时候却是长了不知道多少.废话少说进正题,VS2015安装时注意把Android相关的组件勾选安装, ...
- ExtJS4.2学习(16)制作表单(转)
鸣谢:http://www.shuyangyang.com.cn/jishuliangongfang/qianduanjishu/2013-12-10/188.html --------------- ...
- 什么是 DevSecOps?系列(一)
什么是 DevSecOps? 「DevSecOps」 的作用和意义建立在「每个人都对安全负责」的理念之上,其目标是在不影响安全需求的情况下快速的执行安全决策,将决策传递至拥有最高级别环境信息的人员. ...
- 日志分析-Web
http://my.oschina.net/chenguang/blog/376267 http://my.oschina.net/chenguang/blog/371275 http://my.os ...
- 李洪强漫谈iOS开发[C语言-019]-断点调试
- 如何在Blog中使用feedburner管理RSS订阅
http://www.cnblogs.com/procoder/archive/2010/02/12/feedburner.html