小学计算题版-----高冰冰
一、 计划
1、使用随机函数产生一组(10个)的算数题
2、显示算题界面,开始、完成界面,同步计时(秒)
3、显示对错,统计正确率以及得分,并且统计时间
二、开发
1、需求分析
完成100以内的正整数的加减法题随机产生
2、用户故事
作为一个一年级小学生的家长,我希望制作一个出题软件,完成100以内的正整数的加减法题随机产生,以便减轻我的家庭负担。
3.生成设计文档
创建一个java类,包含加减两个运算方法
4.具体代码
package jisuan;
import java.util.Date;
import java.util.Scanner;
public class main {
private static String time;
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
String name="gbb";
int pass=123456;
int sum1 = 0;//总题数
int sum2 = 0;//对题数
int x,y,i = 1;
int z,choice;
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("请输入你的选择:");
choice = sc.nextInt();
switch(choice)
{
case 1:
System.out.print("请输入你要完成的题目数:");
num = sc.nextInt();
for(i = 1;i <= num;i ++)
{
x = (int)(Math.random() * 100);
y = (int)(Math.random() * 100);
System.out.print(x + "+" + y + "=");
z = sc.nextInt();
if(z == (x + y))
{
System.out.println("恭喜你,回答正确");
sum2 ++;
}
else
{
System.out.println("答案错误,正确答案为:" + x + "+" + y + "=" + (x + y));
}
sum1 ++;
}
break;
case 2:
System.out.print("请输入你要完成的题目数:");
num = sc.nextInt();
for(i = 1;i <= num;)
{
x = (int)(Math.random() * 100);
y = (int)(Math.random() * 100);
if(x > y)
{
System.out.print(x + "-" + y + "=");
z = sc.nextInt();
if(z == (x - y))
{
System.out.println("恭喜你,回答正确");
sum2 ++;
}
else
{
System.out.println("答案错误,正确答案为:" + x + "-" + y + "=" + (x + y));
}
sum1 ++;
i ++;
}
}
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("用户名或密码输入错误");
}
i ++;
}
}

|
高冰冰的所花时间百分比 | 工程师所花时间百分比 | |
| 计划 | |||
|
8 | 10 | |
| 开发 | |||
|
8 | 10 | |
|
35 | 20 | |
|
12 | 10 | |
|
报告 |
|||
|
12 | 10 | |
|
2 | 1 | |
|
5 | 3 | |
| 共花费 | 82 | 64 |
浙公网安备 33010602011771号