学习进度条:
点滴成就 | 学习时间 | 新编写代码行数 | 博客量(篇) | 学到知识点 |
第一周 | 8 | 0 | 0 | 了解软件工程 |
第二周 | 10 | 0 | 1 | 博文一篇 |
第三周 | 15 | 0 | 2 | 选择项目、调查问卷 |
第四周 | 20 | 80 | 0 | 结对编程 |
第五周 | 25 | 330 | 1 | java的学习、软件工程 |
第六周 | 25 | 210 | 0 | 编译原理、软件工程 |
第七周 | 15 | 0 | 0 | 软件系统设计 |
1.题目描述:某公司程序员二柱的小孩上了小学二年级,老师让家长每天出30道(100以内)四则运算题目给小学生做。二柱立马就想到写一个小程序来做这件事。 这个事情可以用很多语言或者工具来实现:
•Excel、C/C++、Java、C#、VB、Unix Shell、Vbscript、Javascript、Perl、 Python、…
2.结对编程对象:李丽莎 2013110420
对方博客地址:http://www.cnblogs.com/tripoon/
对方贡献比列:1:1
照片:
3.代码:
package arithmetic; import java.util.Random; import java.util.Scanner; public class Arithmetic { private static Scanner input = new Scanner(System.in); public static void main(String[] agrs) { int choose; int right = 0; int first = 0; int last = 0; int[] error = new int[30]; int[] errorId = new int[30]; int oper, j = 0, k = 0; int result1 = 0; int result2 = 0; Random random = new Random(); while (true) { System.out.print("是否进行运算: 1.是 2.否\n"); choose = input.nextInt(); if (choose == 1) { for (int i = 0; i < 30; i++) { Scanner input1 = new Scanner(System.in); first = random.nextInt(100); last = random.nextInt(100); oper = random.nextInt(4); switch (oper) { case 0: { System.out.print(i + 1 + ". " + first + "+" + last + "="); result1 = input1.nextInt(); result2 = first + last; if (result1 == result2) right++; else { error[j] = result2; errorId[k] = i + 1; j++; k++; } break; } case 1: { while (first < last) { first = random.nextInt(100); last = random.nextInt(100); } System.out.print(i + 1 + ". " + first + "-" + last + "="); result1 = input1.nextInt(); result2 = first - last; if (result1 == result2) right++; else { error[j] = result2; errorId[k] = i + 1; j++; k++; } break; } case 2: { System.out.print(i + 1 + ". " + first + "*" + last + "="); result1 = input1.nextInt(); result2 = first * last; if (result1 == result2) right++; else { error[j] = result2; errorId[k] = i + 1; j++; k++; } break; } case 3: { if (last == 0) { last = random.nextInt(99) + 1; } while (first % last != 0) { first = random.nextInt(100); last = random.nextInt(99) + 1; } System.out.print(i + 1 + ". " + first + "/" + last + "="); result1 = input1.nextInt(); result2 = first / last; if (result1 == result2) right++; else { error[j] = result2; errorId[k] = i + 1; j++; k++; } break; } } } System.out.print("你一共答对了" + right + "道题\n" + "其中错误的题和其正确答案为:\n"); for (int m = 0; m < j; m++) { System.out.print(errorId[m] + ". " + error[m] + " "); System.out.print("\n"); } } } } }
4.结果
5.总结:
通过这次的结对编程是自己收获颇多!