小学生口算题答题系统———计应193第六组张晴
一. 计划
使用java语言编写小学生口算题卡系统,实现加减法运算,并提交批改
技术难点:
(1) 随机产生100以内的正整数和加减符号结合组成算式
(2) 要剔除减法为负值的运算
(3)任意选择答题页面(加法或减法)
二. 开发
1. 需求分析:
用户故事
作为一名一年级学生家长,我希望制作一个出题软件,完成100以内的加减法运算,以便减轻我的负担。
2、生成设计文档
3、设计复审
4.代码规范
注意代码格式
5、具体设计
使用java语言的实现登录功能,随机产生一组100以内的加减法算式,循环产生显示一组算题,同步计时(秒),显示对错,错误的给出正确答案,统计得分
6.具体编码
public class SZYS { private static String time; public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); String name = "admin"; int pass = 123456; int sum1 = 0; int sum2 = 0; int a, b, c= 1; int d, f; int time;// 所用时间 int num; System.out.println("----------欢迎进入小学生口算题卡系统--------------"); System.out.println("用户名:"); String username = sc.nextLine(); System.out.println("密码:"); int password = sc.nextInt(); if (username.equals(name) && password == pass) { System.out.println("登陆成功"); Date date = new Date(System.currentTimeMillis()); long startMillis = date.getTime(); while (true) { System.out.println("1,加法运算"); System.out.println("2,减法运算"); System.out.println("3,退出系统"); System.out.print("请输入选择:"); f = sc.nextInt(); switch (f) { case 1: System.out.print("请输入要完成的题目数量:"); num = sc.nextInt(); for (c = 1; c <= num; c++) { a = (int) (Math.random() * 100); b = (int) (Math.random() * 100); System.out.print(a + "+" + b + "="); d = sc.nextInt(); if (d == (a + b)) { System.out.println(答对了!!!"); sum2++; } else { System.out.println("很遗憾,打错了哦!!!正确答案为:" + a + "+" + b + "=" + (a + b)); } sum1++; } break; case 2: System.out.print("请输入要完成的题目数量:"); num = sc.nextInt(); for (c = 1; c <= num;) { a = (int) (Math.random() * 100); b = (int) (Math.random() * 100); if (a > b) { System.out.print(a + "-" + b + "="); d = sc.nextInt(); if (d == (a - b)) { System.out.println("答对了!!!"); sum2++; } else { System.out.println("很遗憾,打错了哦!!!正确答案为:" + a + "-" + b + "=" + (a + b)); } sum1++; c++; } } break; case 3: System.out.println("出题总数:" + sum1 + "答对的题数:" + sum2); Date star = new Date(System.currentTimeMillis()); long endMillis = star.getTime(); double usertime = ((endMillis - startMillis) / 1000); System.out.println("答题时间为:" + usertime + "秒"); System.out.println("系统已退出,欢迎下次使用"); System.exit(0); break; default: System.out.println("选择错误,请重新选择"); } } } else { System.out.println("用户名或密码输入错误"); } c++; } }
7、代码复审
8、测试
运行结果
9、测试报告
在出现正确的运行结果之前,出现了好多BUG,使用DeBug模式一步一步运行,并进行代码修改
10、总结
因为做项目的经验少,有很多的不足。希望在下次做项目时能有所改进。
工作所花时间百分比
口算题卡开发 |
预计时间 |
实际记录 |
计划 |
10 |
10 |
|
10 |
6 |
开发 |
85 |
81 |
|
10 |
10 |
|
8 |
7 |
|
7 |
8 |
|
6 |
7 |
|
15 |
17 |
|
30 |
21 |
|
9 |
11 |
报告 |
7 |
5 |
|
3 |
3 |
|
2 |
1 |
|
2 |
1 |
总共花费的时间 |
102 |
96 |