标签:
package fee; import java.util.*; import java.util.Random; public class pp { static Scanner in = new Scanner(System.in); static Random r = new Random(); public static void main(String[] args) { System.out.println("答对了一提获得5分"); System.out.println("输入题目数量:"); int x = in.nextInt(); int fenshu=0; // int r1=r.nextInt(100); // int r2=r.nextInt(100); System.out.println("输入1表示加法2表示减3表示乘4表示除:"); int y = in.nextInt(); switch (y) { case 1: for (int i = 0; i < x; i++) { double r1 = r.nextInt(100); double r2 = r.nextInt(100); System.out.println(r1 + "+" + r2 + "="); double a = in.nextInt(); double b = r1+r2; if(a==b){System.out.println("答对了!获得5分");fenshu=fenshu+5;} else{System.out.println("打错了,正确答案为"+b);} System.out.println("你当前的的分数为"+fenshu); } break; case 2: for (int i = 0; i < x; i++) { double r1 = r.nextInt(100); double r2 = r.nextInt(100); System.out.println(r1 + "-" + r2 + "="); double a = in.nextInt(); double b = r1-r2; if(a==b){System.out.println("答对了!获得5分");fenshu=fenshu+5;} else{System.out.println("打错了,正确答案为"+b);} System.out.println("你当前的的分数为"+fenshu); } break; case 3: for (int i = 0; i < x; i++) { double r1 = r.nextInt(100); double r2 = r.nextInt(100); System.out.println(r1 + "*" + r2 + "="); double a = in.nextInt(); double b = r1*r2; if(a==b){System.out.println("答对了!获得5分");fenshu=fenshu+5;} else{System.out.println("打错了,正确答案为"+b);} System.out.println("你当前的的分数为"+fenshu); } break; case 4: for (int i = 0; i < x; i++) { double r1 = r.nextInt(100); double r2 = r.nextInt(100); System.out.println(r1 + "/" + r2 + "="); double a = in.nextInt(); double b = r1/r2; if(a==b){System.out.println("答对了!获得5分");fenshu=fenshu+5;} else{System.out.println("打错了,正确答案为"+b);} System.out.println("你当前的的分数为"+fenshu); } break; } System.out.println("你获得的分数为"+fenshu); } }
真分数功能没有实现
标签:
原文地址:http://www.cnblogs.com/liwenzhong/p/4381581.html