一、结对信息
1.1 结对编程成员:
蒋勃超:201521123087
谢季努:201521123079
1.2 项目开发的码云地址:https://gitee.com/jbc1132/jbc1/blob/6c8f278bedba41d70802c3334c0afd08b42eafba/jbc1.java
1.3 选择修改的程序代码:
个人博客地址5:http://www.cnblogs.com/NianQiFeng ,源代码:https://git.coding.net/qwx_hh/java-szys.git
1.4 码云提交记录:
二、需求分析:
针对现有代码的改进分析,新开发功能的分析。
现有代码改进分析
目前就发现了两个bug,一个是功能键“复习”,他会回到主页面再次进行做题,功能键与实际内容不符,所以修改了功能键名称为“继续”。
另一个是他的正确率的计算有误,第一次运行程序的时候,计算出来的正确率结果是正确的,当点击了“继续”并再次做题之后,他的正确题数rn会累加,导致正确率计算出错,因此,我们在显示正确率之后令“rn=0.0”,避免他的累加。
程序设计:针对新开发功能做设计,建议使用思维导图。
原本打算用二叉树来做随机算术题的产生。但后来观察了源代码,如果要使用二叉树的话要把他们的源代码全部推翻重来,如此一来,将耗费大量的时间与精力,于是后来还是放弃了,选择了一个较为简单,而且契合恶源代码的方法。
代码如下:
复制代码
import java.util.Random;
import java.util.Scanner;
public class jbc1 {
public static void main(String[] args){
int x,y,z,p,g;
int a,b,c,m,n;
int h = 0;
System.out.printf("请输入需要生成的题目数量:");
Scanner d = new Scanner(System.in);
x = d.nextInt();
for(int i = 0 ; i < x ; i++){
Random aa = new Random();
Random bb = new Random();
Random cc = new Random();
Random mm = new Random();
Random nn = new Random();
a = aa.nextInt(10);
b = bb.nextInt(10);
c = cc.nextInt(4);
m = mm.nextInt(10);
n = nn.nextInt(10);
if(c==0){
if(m==0&&n==0){
m = mm.nextInt(10)+1;
n = nn.nextInt(10)+1;
if(a%m==0&&b%n==0){
y = a + b;
System.out.printf(a+"+"+b+"= ");
Scanner e1 = new Scanner(System.in);
z = e1.nextInt();
if(z==y){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+y);
}
}else if(a%m==0&&b%n!=0){
String l = b + "/" + n;
y = a*n + b ;
System.out.printf(a+"+"+l+"= ");
String k = y + "/"+ n;
Scanner e6 = new Scanner(System.in);
String j = e6.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else if(a%m!=0&&b%n==0){
String l = a + "/" + m;
y = a + b*m;
System.out.printf(l+"+"+b+"= ");
String k = y + "/"+ m;
Scanner e7 = new Scanner(System.in);
String j = e7.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else{
String l1 = a + "/" + m;
String l2 = b + "/" + n;
y = a*n + b*m;
System.out.printf(l1+"+"+l2+"= ");
String k = y + "/"+ n*m;
Scanner e8 = new Scanner(System.in);
String j = e8.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}
}else if(m==0&&n!=0){
m = mm.nextInt(10)+1;
if(a%m==0&&b%n==0){
y = a + b;
System.out.printf(a+"+"+b+"= ");
Scanner e1 = new Scanner(System.in);
z = e1.nextInt();
if(z==y){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+y);
}
}else if(a%m==0&&b%n!=0){
String l = b + "/" + n;
y = a*n + b ;
System.out.printf(a+"+"+l+"= ");
String k = y + "/"+ n;
Scanner e6 = new Scanner(System.in);
String j = e6.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else if(a%m!=0&&b%n==0){
String l = a + "/" + m;
y = a + b*m;
System.out.printf(l+"+"+b+"= ");
String k = y + "/"+ m;
Scanner e7 = new Scanner(System.in);
String j = e7.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else{
String l1 = a + "/" + m;
String l2 = b + "/" + n;
y = a*n + b*m;
System.out.printf(l1+"+"+l2+"= ");
String k = y + "/"+ n*m;
Scanner e8 = new Scanner(System.in);
String j = e8.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}
}else if(m!=0&&n==0){
n = nn.nextInt(10)+1;
if(a%m==0&&b%n==0){
y = a + b;
System.out.printf(a+"+"+b+"= ");
Scanner e1 = new Scanner(System.in);
z = e1.nextInt();
if(z==y){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+y);
}
}else if(a%m==0&&b%n!=0){
String l = b + "/" + n;
y = a*n + b ;
System.out.printf(a+"+"+l+"= ");
String k = y + "/"+ n;
Scanner e6 = new Scanner(System.in);
String j = e6.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else if(a%m!=0&&b%n==0){
String l = a + "/" + m;
y = a + b*m;
System.out.printf(l+"+"+b+"= ");
String k = y + "/"+ m;
Scanner e7 = new Scanner(System.in);
String j = e7.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else{
String l1 = a + "/" + m;
String l2 = b + "/" + n;
y = a*n + b*m;
System.out.printf(l1+"+"+l2+"= ");
String k = y + "/"+ n*m;
Scanner e8 = new Scanner(System.in);
String j = e8.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}
}else{
if(a%m==0&&b%n==0){
y = a + b;
System.out.printf(a+"+"+b+"= ");
Scanner e1 = new Scanner(System.in);
z = e1.nextInt();
if(z==y){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+y);
}
}else if(a%m==0&&b%n!=0){
String l = b + "/" + n;
y = a*n + b ;
System.out.printf(a+"+"+l+"= ");
String k = y + "/"+ n;
Scanner e6 = new Scanner(System.in);
String j = e6.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else if(a%m!=0&&b%n==0){
String l = a + "/" + m;
y = a + b*m;
System.out.printf(l+"+"+b+"= ");
String k = y + "/"+ m;
Scanner e7 = new Scanner(System.in);
String j = e7.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else{
String l1 = a + "/" + m;
String l2 = b + "/" + n;
y = a*n + b*m;
System.out.printf(l1+"+"+l2+"= ");
String k = y + "/"+ n*m;
Scanner e8 = new Scanner(System.in);
String j = e8.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}
}
}
if(c==1){
if(m==0&&n==0){
m = mm.nextInt(10)+1;
n = nn.nextInt(10)+1;
if(a%m==0&&b%n==0){
y = a - b;
System.out.printf(a+"-"+b+"= ");
Scanner e2 = new Scanner(System.in);
z = e2.nextInt();
if(z==y){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+y);
}
}else if(a%m==0&&b%n!=0){
String l = b + "/" + n;
y = a*n - b ;
System.out.printf(a+"-"+l+"= ");
String k = y + "/"+ n;
Scanner e6 = new Scanner(System.in);
String j = e6.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else if(a%m!=0&&b%n==0){
String l = a + "/" + m;
y = a - b*m;
System.out.printf(l+"-"+b+"= ");
String k = y + "/"+ m;
Scanner e7 = new Scanner(System.in);
String j = e7.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else{
String l1 = a + "/" + m;
String l2 = b + "/" + n;
y = a*n - b*m;
System.out.printf(l1+"-"+l2+"= ");
String k = y + "/"+ n*m;
Scanner e8 = new Scanner(System.in);
String j = e8.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}
}else if(m==0&&n!=0){
m = mm.nextInt(10)+1;
if(a%m==0&&b%n==0){
y = a - b;
System.out.printf(a+"-"+b+"= ");
Scanner e1 = new Scanner(System.in);
z = e1.nextInt();
if(z==y){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+y);
}
}else if(a%m==0&&b%n!=0){
String l = b + "/" + n;
y = a*n - b ;
System.out.printf(a+"-"+l+"= ");
String k = y + "/"+ n;
Scanner e6 = new Scanner(System.in);
String j = e6.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else if(a%m!=0&&b%n==0){
String l = a + "/" + m;
y = a - b*m;
System.out.printf(l+"-"+b+"= ");
String k = y + "/"+ m;
Scanner e7 = new Scanner(System.in);
String j = e7.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else{
String l1 = a + "/" + m;
String l2 = b + "/" + n;
y = a*n - b*m;
System.out.printf(l1+"-"+l2+"= ");
String k = y + "/"+ n*m;
Scanner e8 = new Scanner(System.in);
String j = e8.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}
}else if(m!=0&&n==0){
n = nn.nextInt(10)+1;
if(a%m==0&&b%n==0){
y = a - b;
System.out.printf(a+"-"+b+"= ");
Scanner e1 = new Scanner(System.in);
z = e1.nextInt();
if(z==y){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+y);
}
}else if(a%m==0&&b%n!=0){
String l = b + "/" + n;
y = a*n - b ;
System.out.printf(a+"-"+l+"= ");
String k = y + "/"+ n;
Scanner e6 = new Scanner(System.in);
String j = e6.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else if(a%m!=0&&b%n==0){
String l = a + "/" + m;
y = a - b*m;
System.out.printf(l+"-"+b+"= ");
String k = y + "/"+ m;
Scanner e7 = new Scanner(System.in);
String j = e7.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else{
String l1 = a + "/" + m;
String l2 = b + "/" + n;
y = a*n - b*m;
System.out.printf(l1+"-"+l2+"= ");
String k = y + "/"+ n*m;
Scanner e8 = new Scanner(System.in);
String j = e8.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}
}else{
if(a%m==0&&b%n==0){
y = a - b;
System.out.printf(a+"-"+b+"= ");
Scanner e1 = new Scanner(System.in);
z = e1.nextInt();
if(z==y){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+y);
}
}else if(a%m==0&&b%n!=0){
String l = b + "/" + n;
y = a*n - b ;
System.out.printf(a+"-"+l+"= ");
String k = y + "/"+ n;
Scanner e6 = new Scanner(System.in);
String j = e6.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else if(a%m!=0&&b%n==0){
String l = a + "/" + m;
y = a - b*m;
System.out.printf(l+"-"+b+"= ");
String k = y + "/"+ m;
Scanner e7 = new Scanner(System.in);
String j = e7.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else{
String l1 = a + "/" + m;
String l2 = b + "/" + n;
y = a*n - b*m;
System.out.printf(l1+"-"+l2+"= ");
String k = y + "/"+ n*m;
Scanner e8 = new Scanner(System.in);
String j = e8.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}
}
}
if(c==2){
if(m==0&&n==0){
m = mm.nextInt(10)+1;
n = nn.nextInt(10)+1;
if(a%m==0&&b%n==0){
y = a * b;
System.out.printf(a+"x"+b+"= ");
Scanner e3 = new Scanner(System.in);
z = e3.nextInt();
if(z==y){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+y);
}
}else if(a%m==0&&b%n!=0){
String l = b + "/" + n;
y = a*b ;
System.out.printf(a+"x"+l+"= ");
String k = y + "/"+ n;
Scanner e6 = new Scanner(System.in);
String j = e6.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else if(a%m!=0&&b%n==0){
String l = a + "/" + m;
y = b*a;
System.out.printf(l+"x"+b+"= ");
String k = y + "/"+ m;
Scanner e7 = new Scanner(System.in);
String j = e7.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else{
String l1 = a + "/" + m;
String l2 = b + "/" + n;
y = a*b;
System.out.printf(l1+"x"+l2+"= ");
String k = y + "/"+ n*m;
Scanner e8 = new Scanner(System.in);
String j = e8.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}
}else if(m==0&&n!=0){
m = mm.nextInt(10)+1;
if(a%m==0&&b%n==0){
y = a * b;
System.out.printf(a+"x"+b+"= ");
Scanner e1 = new Scanner(System.in);
z = e1.nextInt();
if(z==y){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+y);
}
}else if(a%m==0&&b%n!=0){
String l = b + "/" + n;
y = a*b;
System.out.printf(a+"x"+l+"= ");
String k = y + "/"+ n;
Scanner e6 = new Scanner(System.in);
String j = e6.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else if(a%m!=0&&b%n==0){
String l = a + "/" + m;
y = a*b;
System.out.printf(l+"x"+b+"= ");
String k = y + "/"+ m;
Scanner e7 = new Scanner(System.in);
String j = e7.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else{
String l1 = a + "/" + m;
String l2 = b + "/" + n;
y = a*b;
System.out.printf(l1+"x"+l2+"= ");
String k = y + "/"+ n*m;
Scanner e8 = new Scanner(System.in);
String j = e8.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}
}else if(m!=0&&n==0){
n = nn.nextInt(10)+1;
if(a%m==0&&b%n==0){
y = a * b;
System.out.printf(a+"x"+b+"= ");
Scanner e1 = new Scanner(System.in);
z = e1.nextInt();
if(z==y){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+y);
}
}else if(a%m==0&&b%n!=0){
String l = b + "/" + n;
y = a*b ;
System.out.printf(a+"x"+l+"= ");
String k = y + "/"+ n;
Scanner e6 = new Scanner(System.in);
String j = e6.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else if(a%m!=0&&b%n==0){
String l = a + "/" + m;
y = a*b;
System.out.printf(l+"x"+b+"= ");
String k = y + "/"+ m;
Scanner e7 = new Scanner(System.in);
String j = e7.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else{
String l1 = a + "/" + m;
String l2 = b + "/" + n;
y = a*b;
System.out.printf(l1+"x"+l2+"= ");
String k = y + "/"+ n*m;
Scanner e8 = new Scanner(System.in);
String j = e8.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}
}else{
if(a%m==0&&b%n==0){
y = a * b;
System.out.printf(a+"x"+b+"= ");
Scanner e1 = new Scanner(System.in);
z = e1.nextInt();
if(z==y){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+y);
}
}else if(a%m==0&&b%n!=0){
String l = b + "/" + n;
y = a*b ;
System.out.printf(a+"x"+l+"= ");
String k = y + "/"+ n;
Scanner e6 = new Scanner(System.in);
String j = e6.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else if(a%m!=0&&b%n==0){
String l = a + "/" + m;
y = a*b;
System.out.printf(l+"x"+b+"= ");
String k = y + "/"+ m;
Scanner e7 = new Scanner(System.in);
String j = e7.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else{
String l1 = a + "/" + m;
String l2 = b + "/" + n;
y = a*b;
System.out.printf(l1+"x"+l2+"= ");
String k = y + "/"+ n*m;
Scanner e8 = new Scanner(System.in);
String j = e8.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}
}
}
if(c==3){
if(b==0){
b = bb.nextInt(10)+1;
if(m==0&&n==0){
m = mm.nextInt(10)+1;
n = nn.nextInt(10)+1;
if(a%m==0&&b%n==0){
if(a%b!=0){
String l=a+"/"+b;
System.out.printf(a+"÷"+b+"= ");
Scanner e4 = new Scanner(System.in);
String p1 = e4.next();
if(p1.equals(l)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+l);
}
}else{
p = a / b;
System.out.printf(a+"÷"+b+"= ");
Scanner e5 = new Scanner(System.in);
g = e5.nextInt();
if(p==g){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+p);
}
}
}else if(a%m==0&&b%n!=0){
String l = b + "/" + n;
if(a==0){System.out.println(a+"÷"+l+"= ");
Scanner e6 = new Scanner(System.in);
p = e6.nextInt();
if(p==0){System.out.println("回答正确!");h++;
continue;}else{System.out.println("回答错误!正确答案是0");continue;}
}
y = a*n ;
System.out.printf(a+"÷"+l+"= ");
String k = y + "/"+ b;
Scanner e6 = new Scanner(System.in);
String j = e6.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else if(a%m!=0&&b%n==0){
String l = a + "/" + m;
y = a;
System.out.printf(l+"÷"+b+"= ");
String k = y + "/"+ m*b;
Scanner e7 = new Scanner(System.in);
String j = e7.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else{
String l1 = a + "/" + m;
String l2 = b + "/" + n;
y = a*n;
System.out.printf(l1+"÷"+l2+"= ");
String k = y + "/"+ b*m;
Scanner e8 = new Scanner(System.in);
String j = e8.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}
}else if(m==0&&n!=0){
m = mm.nextInt(10)+1;
if(a%m==0&&b%n==0){
if(a%b!=0){
String l=a+"/"+b;
System.out.printf(a+"÷"+b+"= ");
Scanner e4 = new Scanner(System.in);
String p1 = e4.next();
if(p1.equals(l)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+l);
}
}else{
p = a / b;
System.out.printf(a+"÷"+b+"= ");
Scanner e5 = new Scanner(System.in);
g = e5.nextInt();
if(p==g){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+p);
}
}
}else if(a%m==0&&b%n!=0){
String l = b + "/" + n;
if(a==0){System.out.println(a+"÷"+l+"= ");
Scanner e6 = new Scanner(System.in);
p = e6.nextInt();
if(p==0){System.out.println("回答正确!");h++;
continue;}else{System.out.println("回答错误!正确答案是0");continue;}
}
y = a*n ;
System.out.printf(a+"÷"+l+"= ");
String k = y + "/"+ b;
Scanner e7 = new Scanner(System.in);
String j = e7.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else if(a%m!=0&&b%n==0){
String l = a + "/" + m;
y = a;
System.out.printf(l+"÷"+b+"= ");
String k = y + "/"+ m*b;
Scanner e7 = new Scanner(System.in);
String j = e7.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else{
String l1 = a + "/" + m;
String l2 = b + "/" + n;
y = a*n;
System.out.printf(l1+"÷"+l2+"= ");
String k = y + "/"+ b*m;
Scanner e8 = new Scanner(System.in);
String j = e8.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}
}else if(m!=0&&n==0){
n = nn.nextInt(10)+1;
if(a%m==0&&b%n==0){
if(a%b!=0){
String l=a+"/"+b;
System.out.printf(a+"÷"+b+"= ");
Scanner e4 = new Scanner(System.in);
String p1 = e4.next();
if(p1.equals(l)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+l);
}
}else{
p = a / b;
System.out.printf(a+"÷"+b+"= ");
Scanner e5 = new Scanner(System.in);
g = e5.nextInt();
if(p==g){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+p);
}
}
}else if(a%m==0&&b%n!=0){
String l = b + "/" + n;
if(a==0){System.out.println(a+"÷"+l+"= ");
Scanner e6 = new Scanner(System.in);
p = e6.nextInt();
if(p==0){System.out.println("回答正确!");h++;
continue;}else{System.out.println("回答错误!正确答案是0");continue;}
}
y = a*n ;
System.out.printf(a+"÷"+l+"= ");
String k = y + "/"+ b;
Scanner e7 = new Scanner(System.in);
String j = e7.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else if(a%m!=0&&b%n==0){
String l = a + "/" + m;
y = a;
System.out.printf(l+"÷"+b+"= ");
String k = y + "/"+ m*b;
Scanner e7 = new Scanner(System.in);
String j = e7.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else{
String l1 = a + "/" + m;
String l2 = b + "/" + n;
y = a*n;
System.out.printf(l1+"÷"+l2+"= ");
String k = y + "/"+ b*m;
Scanner e8 = new Scanner(System.in);
String j = e8.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}
}else{
if(a%m==0&&b%n==0){
if(a%b!=0){
String l=a+"/"+b;
System.out.printf(a+"÷"+b+"= ");
Scanner e4 = new Scanner(System.in);
String p1 = e4.next();
if(p1.equals(l)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+l);
}
}else{
p = a / b;
System.out.printf(a+"÷"+b+"= ");
Scanner e5 = new Scanner(System.in);
g = e5.nextInt();
if(p==g){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+p);
}
}
}else if(a%m==0&&b%n!=0){
String l = b + "/" + n;
if(a==0){System.out.println(a+"÷"+l+"= ");
Scanner e6 = new Scanner(System.in);
p = e6.nextInt();
if(p==0){System.out.println("回答正确!");h++;
continue;}else{System.out.println("回答错误!正确答案是0");continue;}
}
y = a*n ;
System.out.printf(a+"÷"+l+"= ");
String k = y + "/"+ b;
Scanner e6 = new Scanner(System.in);
String j = e6.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else if(a%m!=0&&b%n==0){
String l = a + "/" + m;
y = a;
System.out.printf(l+"÷"+b+"= ");
String k = y + "/"+ m*b;
Scanner e7 = new Scanner(System.in);
String j = e7.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else{
String l1 = a + "/" + m;
String l2 = b + "/" + n;
y = a*n;
System.out.printf(l1+"÷"+l2+"= ");
String k = y + "/"+ b*m;
Scanner e8 = new Scanner(System.in);
String j = e8.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}
}
}else{
//p =(float) a / b;
if(m==0&&n==0){
m = mm.nextInt(10)+1;
n = nn.nextInt(10)+1;
if(a%m==0&&b%n==0){
if(a%b!=0){
String l=a+"/"+b;
System.out.printf(a+"÷"+b+"= ");
Scanner e4 = new Scanner(System.in);
String p1 = e4.next();
if(p1.equals(l)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+l);
}
}else{
p = a / b;
System.out.printf(a+"÷"+b+"= ");
Scanner e5 = new Scanner(System.in);
g = e5.nextInt();
if(p==g){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+p);
}
}
}else if(a%m==0&&b%n!=0){
String l = b + "/" + n;
y = a*n ;
System.out.printf(a+"÷"+l+"= ");
String k = y + "/"+ b;
Scanner e6 = new Scanner(System.in);
String j = e6.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else if(a%m!=0&&b%n==0){
String l = a + "/" + m;
if(a==0){System.out.println(a+"÷"+l+"= ");
Scanner e6 = new Scanner(System.in);
p = e6.nextInt();
if(p==0){System.out.println("回答正确!");h++;
continue;}else{System.out.println("回答错误!正确答案是0");continue;}
}
y = a;
System.out.printf(l+"÷"+b+"= ");
String k = y + "/"+ m*b;
Scanner e7 = new Scanner(System.in);
String j = e7.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else{
String l1 = a + "/" + m;
String l2 = b + "/" + n;
y = a*n;
System.out.printf(l1+"÷"+l2+"= ");
String k = y + "/"+ b*m;
Scanner e8 = new Scanner(System.in);
String j = e8.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}
}else if(m==0&&n!=0){
m = mm.nextInt(10)+1;
if(a%m==0&&b%n==0){
if(a%b!=0){
String l=a+"/"+b;
System.out.printf(a+"÷"+b+"= ");
Scanner e4 = new Scanner(System.in);
String p1 = e4.next();
if(p1.equals(l)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+l);
}
}else{
p = a / b;
System.out.printf(a+"÷"+b+"= ");
Scanner e5 = new Scanner(System.in);
g = e5.nextInt();
if(p==g){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+p);
}
}
}else if(a%m==0&&b%n!=0){
String l = b + "/" + n;
if(a==0){System.out.println(a+"÷"+l+"= ");
Scanner e6 = new Scanner(System.in);
p = e6.nextInt();
if(p==0){System.out.println("回答正确!");h++;
continue;}else{System.out.println("回答错误!正确答案是0");continue;}
}
y = a*n ;
System.out.printf(a+"÷"+l+"= ");
String k = y + "/"+ b;
Scanner e6 = new Scanner(System.in);
String j = e6.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else if(a%m!=0&&b%n==0){
String l = a + "/" + m;
y = a;
System.out.printf(l+"÷"+b+"= ");
String k = y + "/"+ m*b;
Scanner e7 = new Scanner(System.in);
String j = e7.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else{
String l1 = a + "/" + m;
String l2 = b + "/" + n;
y = a*n;
System.out.printf(l1+"÷"+l2+"= ");
String k = y + "/"+ b*m;
Scanner e8 = new Scanner(System.in);
String j = e8.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}
}else if(m!=0&&n==0){
n = nn.nextInt(10)+1;
if(a%m==0&&b%n==0){
if(a%b!=0){
String l=a+"/"+b;
System.out.printf(a+"÷"+b+"= ");
Scanner e4 = new Scanner(System.in);
String p1 = e4.next();
if(p1.equals(l)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+l);
}
}else{
p = a / b;
System.out.printf(a+"÷"+b+"= ");
Scanner e5 = new Scanner(System.in);
g = e5.nextInt();
if(p==g){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+p);
}
}
}else if(a%m==0&&b%n!=0){
String l = b + "/" + n;
if(a==0){System.out.println(a+"÷"+l+"= ");
Scanner e6 = new Scanner(System.in);
p = e6.nextInt();
if(p==0){System.out.println("回答正确!");h++;
continue;}else{System.out.println("回答错误!正确答案是0");continue;}
}
y = a*n ;
System.out.printf(a+"÷"+l+"= ");
String k = y + "/"+ b;
Scanner e7 = new Scanner(System.in);
String j = e7.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else if(a%m!=0&&b%n==0){
String l = a + "/" + m;
y = a;
System.out.printf(l+"÷"+b+"= ");
String k = y + "/"+ m*b;
Scanner e7 = new Scanner(System.in);
String j = e7.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else{
String l1 = a + "/" + m;
String l2 = b + "/" + n;
y = a*n;
System.out.printf(l1+"÷"+l2+"= ");
String k = y + "/"+ b*m;
Scanner e8 = new Scanner(System.in);
String j = e8.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}
}else{
if(a%m==0&&b%n==0){
if(a%b!=0){
String l=a+"/"+b;
System.out.printf(a+"÷"+b+"= ");
Scanner e4 = new Scanner(System.in);
String p1 = e4.next();
if(p1.equals(l)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+l);
}
}else{
p = a / b;
System.out.printf(a+"÷"+b+"= ");
Scanner e5 = new Scanner(System.in);
g = e5.nextInt();
if(p==g){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+p);
}
}
}else if(a%m==0&&b%n!=0){
String l = b + "/" + n;
if(a==0){System.out.println(a+"÷"+l+"= ");
Scanner e6 = new Scanner(System.in);
p = e6.nextInt();
if(p==0){System.out.println("回答正确!");h++;
continue;}else{System.out.println("回答错误!正确答案是0");continue;}
}
y = a*n ;
System.out.printf(a+"÷"+l+"= ");
String k = y + "/"+ b;
Scanner e7 = new Scanner(System.in);
String j = e7.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else if(a%m!=0&&b%n==0){
String l = a + "/" + m;
y = a;
System.out.printf(l+"÷"+b+"= ");
String k = y + "/"+ m*b;
Scanner e7 = new Scanner(System.in);
String j = e7.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}else{
String l1 = a + "/" + m;
String l2 = b + "/" + n;
y = a*n;
System.out.printf(l1+"÷"+l2+"= ");
String k = y + "/"+ b*m;
Scanner e8 = new Scanner(System.in);
String j = e8.next();
if(j.equals(k)){
System.out.println("回答正确!");
h++;
}else{
System.out.println("回答错误!正确答案是"+k);
}
}
}
}
}
}
System.out.println("总共"+x+"题,"+"恭喜答对"+h+"题");
System.out.println("正确率为"+(float)h/x);
}
}
5.PSP表格
6.小结感受:结对编程真的能够带来1+1>2的效果吗?通过这次结对编程,请谈谈你的感受和体会。
答:这次的结对编程让我深深感觉到编程的难度,并且有着许多需要自己掌握的地方,现在的我需要继续的努力来弥补自己的不足和落后
原文地址:https://www.cnblogs.com/xjn12138/p/8646825.html