打印答题时间、正确题目数
来源:互联网 发布:网络用语泥石流 编辑:程序博客网 时间:2024/05/19 16:36
/*What's 25-32 ? 556What's 34-13 ? 90What's 69-91 ? -22What's 66-86 ? 20What's 8-51 ? -43Correct count is: 2Test time is: 0 hour 8 minute 24 seconds25-32=556 wrong.34-13=90 wrong.69-91=-22 Right.66-86=20 wrong.8-51=-43 Right.*/import java.util.Scanner;public class SubtrationQuizloop { public static void main (String[] args) { long startSeconds = System.currentTimeMillis() / 1000; Scanner input = new Scanner(System.in); int correctCount = 0, answer; //Count the number of the correct questions final int NUMBER_OF_QUESTIONS = 5; final int PER_SECONDS_MINUTE = 60; String output = ""; // output string is initially empty String isRight = ""; for (int count = 0; count < NUMBER_OF_QUESTIONS; count++) { int number1 = (int)(Math.random() * 100); int number2 = (int)(Math.random() * 100); System.out.print("What's " + number1 + "-" + number2 + " ? "); answer = input.nextInt(); if(number1 - number2 == answer) { correctCount++; isRight = "Right."; } else isRight = "wrong."; output += number1 + "-" + number2 + "=" + answer + "\t" + isRight + "\n"; } long endSeconds = System.currentTimeMillis() / 1000; int totalSeconds = (int)(endSeconds - startSeconds); int seconds = totalSeconds % PER_SECONDS_MINUTE; totalSeconds /= PER_SECONDS_MINUTE; int minute = totalSeconds % PER_SECONDS_MINUTE; int hour = totalSeconds / PER_SECONDS_MINUTE; System.out.println("Correct count is: " + correctCount); System.out.println("Test time is: " + hour + " hour " + minute + " minute " + seconds + " seconds"); System.out.println(output); }}
0 0
- 打印答题时间、正确题目数
- 牛客网答题运行时间改善
- 第三周项目3-打印一个正确的时间
- Scanner ,Math.random()答题正确统计
- 程序3.题目:打印出所有的"水仙花数
- 五十道编程题目03 打印水仙花数
- 答题
- FOR循环、游标、时间值函 数、转换函数题目
- 打印时间
- 打印时间
- “数据库工程师评选”答题总结!原来题目不太难!
- PMP考试 实施整体变更控制相关题目答题技巧
- 腾讯2014软件开发笔试题目简答题
- 打印前20个平凡数(某公司校园招聘笔试题目)
- 题目:输入数字n,按顺序打印从1到n位十进制数;
- 五十道编程小题目 --- 03打印出所有的"水仙花数"java
- 题目9:打印日期
- 题目1186:打印日期
- CodeForces 550D - Regular Bridge(构造)
- Android Studio使用Lint进行工程优化
- android 读取系统文件 wpa_supplicant
- VideoView大小屏幕切换的总结
- 使用Fragment和RadioGroup实现类似ios的tabbar的效果
- 打印答题时间、正确题目数
- 路由配置
- spring SecurityContext 退出处理
- 【C#】Entity Framework 增删改查和事务操作
- 值得推荐的C/C++框架和库
- SpringMvc POST中文乱码解决方案
- Leetcode#77||
- 【网络流24题之餐巾计划】xoj 1247
- ViewPager点击每一项设置的监听