JAVA编码高手快来!!

来源:百度知道 编辑:UC知道 时间:2024/05/12 17:14:08
课题:算术运算测试
功能要求:该程序用字符界面实现十道100以内加减法数学题,能根据题目计算出答案,与输入答案对比,判断做题是否正确,最后计算分数。
界面要求:用字符界面实现、也可用图形界面
最好用命令提示符界面实现!!!!!!!!!

package test;

import java.util.Scanner;
public class Test {
static int getNum(){
return (int)(Math.random()*100);
}
public static void main(String[] args) {
int count=0;
int right=0;
while(count!=10){
int a=getNum(),b=getNum();
int c=a+b;
System.out.println(a+"+"+b+"=?");
Scanner sc=new Scanner(System.in);
int result=sc.nextInt();
if(c==result){
System.out.println("答案正确!");
right++;
}else{
System.out.println("答案错误!");
}
count++;
}
System.out.println("你的得分为"+(right*10)+"分!");
}
}

import java.io.*;
public class TestIO {
public static void main(String[] args) {
// TODO Auto-generated method stub
BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
int a,b,c = 0;
try {
for(int i