軟工結對編程作業
阿新 • • 發佈:2018-03-25
tin .net tee ann 題目 IT random 記錄 項目
一、結對信息
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的效果嗎?通過這次結對編程,請談談你的感受和體會。
答:這次的結對編程讓我深深感覺到編程的難度,並且有著許多需要自己掌握的地方,現在的我需要繼續的努力來彌補自己的不足和落後
軟工結對編程作業