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 ...
随机推荐
- merge into 和 update 的效率对比
以前只考虑 merge into 只是在特定场合下方便才使用的,今天才发现,merge into 竟然会比 update 在更新数据时有这么大的改进.其实呢,merge into部分的update和u ...
- Mac操作系统常用快捷键
复制:cmd+c 粘贴:cmd+v 剪切:先cmd+c,再cmd+opt+v 显示桌面:cmd+F3 切换输入法:cmd+space 打开Spotlight:ctrl+s ...
- VS2010 代码自动对齐 快捷键
VS2010 代码自动对齐 快捷键 先全选代码 ctrl+K+F MATLAB代码自动对齐 快捷键 先全选代码 ctrl+I
- Burp Suite教程(英文版)
In this article, we are going to see another powerful framework that is used widely in pen-testing. ...
- Altium Designer完美双屏显示方法演示
布线时我们往往需要对一些信号线做特别的走线处理,这样需要边布线边对照原理图,在protel99中那是一个很痛苦的事,在Altium Designer中这种情况将变很简单. 硬件要求,笔记本+外接显示器 ...
- Android网络请求心路历程
HTTP请求&响应 既然说从入门级开始就说说Http请求包的结构.一次请求就是向目标服务器发送一串文本.什么样的文本?有下面结构的文本.HTTP请求包结构 例子: 1 2 3 4 5 6 7 ...
- MySQL can’t specify target table for update in FROM clause
翻译:MySQL不能指定更新的目标表在FROM子句 源SQL语句: delete from t_official_sys_user where USER_NAME IN(SELECT USER_NAM ...
- make menuconfig出错
make[1]: *** [scripts/kconfig/mconf] Error 1 make: *** [menuconfig] Error 2 fixed: sudo apt-get inst ...
- 【HDOJ】2065 "红色病毒"问题
刚开始看这道题目的时候,完全没看出来是递推.看了网上大牛的分析.立刻就明白了.其实无论字符串长度为多少,都可以将该长度下的组合分成四种情况S1(A偶数C偶数).S2(A偶数C奇数).S3(A奇数C偶数 ...
- Android开发之PagerAdapter
public class ViewPagerAdapter extends PagerAdapter { private List<View> views; private Context ...