标签:整数 新技术 person exti for 学习 bre dev void
一个命令行程序实现:
统计正确率
import java.util.Scanner;
public class question {
public static void main(String[] args)
{
int k;
int total,answer=0;
int answer2;
int count=0;
System.out.println("请输入你需要练习的题目数:");
Scanner input=new Scanner(System.in
);
total=input.nextInt();
question question=new question();
for(int n=0;n<total;n++)
{
int i=(int)(Math.random()*100);
int j=(int)(Math.random()*100);
switch((int)(Math.random()*4))
{
case 0:
System.out.println(i+"+"+j+"=");
answer=i+j;
break;
case 1:
if(i<j)
{
int temp=i;
i=j;
j=temp;
}
System.out.println(i+"-"+j+"=");
answer=i-j;
break;
case 2:
System.out.println(i+"*"+j+"=");
answer=i*j;
break;
case 3:
while(j==0)
j= (int)(Math.random()*100);
System.out.println(i+"/"+j+"=");
answer=i/j;
break;
}
Scanner input2=new Scanner(System.in
);
answer2=input2.nextInt();
if(answer2==answer){
System.out.println("正确!");
count++;
}
else{
System.out.println("错误!");
}
}
float cent=(float)count/(float)total;
System.out.println("正确率为"+cent);
}
}
PSP2.1 | Personal Software Process Stages | 预估耗时(分钟) | 实际耗时(分钟) |
---|---|---|---|
· Test | · 测试(自我测试,修改代码,提交修改) | 20min | 25min |
Planning | 计划 | 15min | 10min |
· Estimate | · 估计这个任务需要多少时间 | 240min | 260min |
Development | 开发 | 40min | 35min |
· Analysis | · 需求分析 (包括学习新技术) | 15min | 35min |
· Coding Standard | · 代码规范 (为目前的开发制定合适的规范) | 10min | 15min |
· Coding | · 具体编码 | 2h | 100min |
· Code Review | · 代码复审 | 30min | 40min |
标签:整数 新技术 person exti for 学习 bre dev void
原文地址:https://www.cnblogs.com/akashi/p/8850258.html