另一个四则运算

import com.sun.javaws.IconUtil;
//这个跟那个差不多 进步在于 类 至于三年级没写 道理相同

import java.util.Scanner;

public class Main {
public static void main(String[] args) {
String []cun =new String[10000];
int []daan =new int [1000];
double [ ]shuru = new double [1000];
String []cuotiji = new String[1000];
double []cuotidaan = new double[1000];
String []error = new String[100];
String[] cunfuhao = new String[10000];
int sum = 0;
int count=0;
int right=0;
while (true) {
System.out.println("欢迎来到四则运算");
System.out.println("1.小学二年级口算题");
System.out.println("2.小学三年级口算题");
System.out.println("3.小学四年级口算题");
System.out.println("请选择年级:");
two t = new two();
three th = new three();
four f = new four();
Scanner sc =new Scanner(System.in);
int choose = sc.nextInt();


loop1:switch (choose){
case 1: {

loop2:while (true) {
System.out.println("请输入出题个数");
int chutishu = sc.nextInt();
int jishu = 0;
loop:while (true){
int num1 = t.shuzi(100,0);
char c = t.caozuofu();
int num2 = t.shuzi(100,0);
if(c=='/'&&num1%num2!=0){
continue;
}
System.out.println(num1+" " + c +" "+ num2 + " = " );
System.out.println("请输入答案:");
int answer = sc.nextInt();
boolean flag1 =t.panduan(num1,c,num2,answer);
if(!flag1){
t.cundaan(c,num1,num2,daan,count);
error[count] = num1 +" " + c +" "+ num2 + " = ";
count++;
sum++;
jishu++;
}
else {
right++;
sum++;
jishu++;
}
if(jishu == chutishu){
System.out.println("1.下一套");
System.out.println("2.做错题");
System.out.println("3.返回主界面");
System.out.println("4.退出");
int choose2 = sc.nextInt();
switch (choose2){
case 1:{
break loop;
}
case 2:{
zuocuoti(error,count,daan);
}
case 3:{
break loop1;
}
case 4:{
System.exit(0);
}
}
}
}
}
}
case 2 :{
loop2:while (true) {
System.out.println("请输入需要的操作数:");
int m = sc.nextInt();
System.out.println("请输入需要的题目个数:");
int n = sc.nextInt();
for (int i = 0; i < n; i++) {
int an = 0;
String s=null;
for (int j = 0; j < m; j++) {
int num = th.shuzi(1000,0);
System.out.print(num+" ");
char c='.';
if(j==0){
an=num;
}
else {
an = th.jisuan(an,c,num);
}
c = th.caozuofu();
if(j==m-1){
c='=';
}
System.out.print(c+" ");
if(j==0){
s=num + " "+c+" ";
}
else {
s += num + " "+c+" ";
}
}
System.out.println("");
System.out.println("请输入你的答案:");
int answer = sc.nextInt();
if(answer!= an){
error[count]=s;
count++;
}
else {
right++;
}
}
System.out.println("1.下一套");
System.out.println("2.做错题");
System.out.println("3.返回主界面");
System.out.println("4.退出");
int choose2 = sc.nextInt();
switch (choose2){
case 1:{
break;
}
case 2:{
zuocuoti(error,count,daan);
}
case 3:{
break loop1;
}
case 4:{
System.exit(0);
}
}
}
}
case 3:{

break;
}
}
}
}
public static void zuocuoti(String []error,int count,int []daan){
for (int i = 0; i < count; i++) {
System.out.println(error[i]);
System.out.println("请输入答案");
Scanner sc =new Scanner(System.in);
int answer = sc.nextInt();
if(answer!=daan[i]){
System.out.println("很遗憾,又答错了");
}
else {
System.out.println("恭喜你,答对了");
}
}
}

}
posted @ 2022-10-10 19:29  会秃头的小白  阅读(16)  评论(0编辑  收藏  举报