课堂3
阶段1: 1、定义主界面菜单,
1、参数设置
2、小学二年级口算题
3、小学三年级口算题
4、小学四年级口算题
5、错题集
其中参数设置包括出题个数(缺省值为30)、操作数数值范围。
小学二年级口算题操作数为两个、可进行加减乘除运算(除法必须可以整除),操作数范围不超过100.
小学三年级口算题操作数不超过4个,可以进行加减乘除,操作数范围不超过1000.(要求采用继承小学二年级出题类的方式,实现小学三年级的出题类)
小学四年级口算题操作数不超过5个,可以进行加减乘除,还可以加入括号运算。 (要求采用继承小学三年级出题类的方式,实现小学四年级的出题类)
阶段2:
1、学生实时答题结束后,可以选择是否进行下一套题目答题,如果选择是,则抽取下一套题进行答题,答题结束可以通过查看错题本,查询今日做题正确率。
2、也可以针对错题进行二次答题。
主操作类:
1 package SiZe;
2 import java.util.*;
3 import java.util.Random;
4 import java.util.Scanner;
5 public class sizeyunsuan {
6 public static void main(String[] args) {
7
8 Scanner scan =new Scanner(System.in);
9 int a,b,n,num,sum=0;
10 menu.menu();
11
12 a=scan.nextInt();
13
14 switch(a) {
15 case 1:System.out.println("请输入需要的题目数:");
16 ShuJu.N=scan.nextInt();
17 System.out.println("请输入需要的操作数(操作数需要大于等于2):");
18 ShuJu.n=scan.nextInt();
19 System.out.println("请输入数据位数限制(2/3/4)");
20 ShuJu.a=scan.nextInt();
21 System.out.println(" ");
22 menu.menu();
23 a=scan.nextInt();
24
25
26 switch(a) {
27
28 case 2:Second.second();
29 System.out.println("是否查看错题集?(1是/2否)");
30 b=scan.nextInt();
31 if(b==1) {
32 InTo.jixun();
33 break;
34 }
35 if(b==2) {
36
37 break;
38 }
39
40 case 3:Third.third();
41 System.out.println("是否查看错题集?(1是/2否)");
42 b=scan.nextInt();
43 if(b==1) {
44 InTo.jixun();
45 break;
46 }
47 if(b==2) {
48
49 break;
50 }
51 case 4:Fourth.fourth();
52 System.out.println("是否查看错题集?(1是/2否)");
53 b=scan.nextInt();
54 if(b==1) {
55 InTo.jixun();
56 break;
57 }
58 if(b==2) {
59
60 break;
61 }
62 case 5:InTo.jixun();
63 }
64 }
65 }
66
67
68 }
菜单类
1 package SiZe;
2 import java.util.Scanner;
3 public class menu {
4 public static void menu() {
5 System.out.println("1.参数设置");
6 System.out.println("2.小学二年级口算题");
7 System.out.println("3.小学三年级口算题");
8 System.out.println("4.小学四年级口算题");
9 System.out.println("5.错题集");
10 System.out.println("请选择:");
11
12 }
13 }
数据类
1 package SiZe;
2 import java.util.Scanner;
3 import java.util.Random;
4 public class ShuJu {
5 private int shuju1;//数据1
6 private int shuju2;//数据2
7
8 private String fuhao;//符号
9 static int N;//题目个数
10 static int n;//操作数个数
11 static int a;//数据位数
12 public static int shuju1() {
13
14 int shuju1=0;
15 Random r= new Random();
16 if(a==2)
17 { shuju1=r.nextInt(99);}
18 else if(a==3)
19 { shuju1=r.nextInt(999);}
20 else if(a==4)
21 { shuju1=r.nextInt(9999); }
22 return shuju1;
23
24 }
25 public static int shuju2() {
26
27 int shuju2=0;
28 Random r= new Random();
29 if(a==2)
30 { shuju2=r.nextInt(99);}
31 else if(a==3)
32 { shuju2=r.nextInt(999);}
33 else if(a==4)
34 { shuju2=r.nextInt(9999); }
35 return shuju2;
36
37 }
38 public static char yunsuan( ) {
39 Random r=new Random();
40 int t=(int)r.nextInt(4);
41 char fuhao=' ';
42 switch(t) {
43 case 0:
44 fuhao = '+';
45 break;
46 case 1:
47 fuhao = '-';
48 break;
49 case 2:
50 fuhao = '*';
51 break;
52 case 3:
53 fuhao = '/';
54 break;
55 }
56 return fuhao;
57 }
58
59 public int num() {
60
61 return N;
62
63 }
64
65 ShuJu(int shuju1,int shuju2,String fuhao,int num,int n){
66 this.shuju1=shuju1;
67 this.shuju2=shuju2;
68 this.fuhao=fuhao;
69 this.N=num;
70 this.n=n;
71 }
72
73
74 }
判断+计算+错题重练
1 package SiZe;
2 import java.util.Scanner;
3 public class InTo {
4 private static ShuJu sj;
5 static int nnum=0;
6 static int ccount=0;
7 static int cuoticount=0;
8 static String []arr = new String[100000];
9 static int []zqda = new int[100000];
10 static int []cishu = new int[100000];
11 public static void chuti()
12 {
13 int a = sj.shuju1();
14 int b = sj.shuju2();
15 char c = sj.yunsuan();
16 String str = ""+a+c+b;
17 int []cunshu = new int[1000];
18 char []cunfuhao =new char[1000];
19 int shu=0;
20 int fuhao=0;
21 if(c=='*')
22 {
23 cunshu[shu]=a*b;
24 }
25 else if(c=='/')
26 {
27 cunshu[fuhao]=a/b;
28 }
29 else
30 {
31 cunshu[shu]=a;
32 shu++;
33 cunshu[shu]=b;
34 cunfuhao[fuhao]=c;
35 }
36
37 for(int i=2;i<sj.n;i++)
38 {
39 int zenjiashu = sj.shuju1();
40 char zenjiac = sj.yunsuan();
41 if(zenjiac=='*')
42 {
43 cunshu[shu]=cunshu[shu]*zenjiashu;
44 }
45 else if(c=='/')
46 {
47 cunshu[shu]=cunshu[shu]/zenjiashu;
48 }
49 else
50 {
51 shu++;
52 cunshu[shu]=zenjiashu;
53 fuhao++;
54 cunfuhao[fuhao]=zenjiac;
55 }
56 str = str + zenjiac + zenjiashu;
57 }
58 int zhengquedaan=cunshu[0];
59 int cou=0;
60 for(int j=0;j<=fuhao;j++)
61 {
62 if(cunfuhao[cou]=='+')
63 {
64 zhengquedaan+=cunshu[cou+1];
65 }
66 else
67 {
68 zhengquedaan-=cunshu[cou+1];
69 }
70 }
71 chutimu(str,zhengquedaan);
72 }
73
74 public static void chutimu(String str,int zhengquedaan)
75 {
76 if(ccount<sj.N)
77 {
78 arr[ccount]=str;
79 zqda[ccount]=zhengquedaan;
80 System.out.println(arr[ccount]+"=");
81 int daan;
82 Scanner sc = new Scanner(System.in);
83 daan = sc.nextInt();
84 if(daan!=zhengquedaan)
85 {
86 System.out.println("答案错误");
87 cishu[ccount]=1;
88 cuoticount++;
89 }
90 else
91 {
92 System.out.println("答案正确");
93 cishu[ccount]=0;
94 }
95 ccount++;
96 chuti();
97 }
98 else
99 {
100 System.out.println("错误率"+cuoticount*100/sj.N+"%");
101
102 }
103 }
104 public static void jixun()
105 {
106 System.out.println("请选择: "+"\n"+
107 "1.错题重做 "+"\n"+
108 "2.再练一套 "+"\n"+
109 "3.退出系统");
110 Scanner sc = new Scanner(System.in);
111 int xuan;
112 xuan = sc.nextInt();
113 switch(xuan)
114 {
115 case 1:cuoti();break;
116 case 2:zailian();break;
117 case 3:System.out.println("系统已退出,欢迎下次使用!");
118 System.exit(0);
119 }
120 }
121 //做错题
122 public static void cuoti()
123 {
124 nnum=cuoticount;
125 cuoticount=0;
126 for(int i=0;i<sj.N;i++)
127 {
128 if(cishu[i]==1)
129 {
130 System.out.println(arr[i]+"=");
131 Scanner sc = new Scanner(System.in);
132 int da;
133 da = sc.nextInt();
134 if(da!=zqda[i])
135 {
136 System.out.println("答案错误");
137 cuoticount++;
138 }
139 else
140 {
141 cishu[i]=0;
142 System.out.println("答案正确");
143 }
144 }
145 }
146 System.out.println("错误率"+cuoticount*100/nnum+"%");
147 jixun();
148 }
149 //再练
150 public static void zailian()
151 {
152 ccount=0;
153 cuoticount=0;
154 nnum=0;
155 chuti();
156 }
157 }
二年级类
1 package SiZe;
2 import java.util.*;
3 import java.util.Scanner;
4 public class Second {
5 public static void second() {
6
7 Scanner scan =new Scanner(System.in);
8 ShuJu sj ;
9 InTo.chuti();}
10
11 }
三年级类继承二年级类
1 package SiZe;
2 import java.util.Scanner;
3 public class Third extends Second {
4 public static void third() {
5
6 Scanner scan =new Scanner(System.in);
7 ShuJu sj ;
8
9 InTo.chuti();
10 }
11
12 }
四年级继承三年级类
1 package SiZe;
2 import java.util.Scanner;
3 public class Fourth extends Third{
4 public static void fourth() {
5
6 Scanner scan =new Scanner(System.in);
7 ShuJu sj ;
8
9 InTo.chuti();}
10 }

浙公网安备 33010602011771号