zoukankan      html  css  js  c++  java
  • 结对项目

     
    点滴成就 学习时间 新编写代码行数 博客量 学到知识点
    第一周 11 0 0 了解软件工程
    第二周 11 0 1 了解软件工程
    第三周 11 0 1 用例图
    第四周 12 25 0 结对编程
    第五周 12 30 1 类图
    第六周 12 60 0 软件工程
    第七周 13 40 1 测试

    package com.mindu.FourArithmeticOperations;

    import java.util.Random;
    import java.util.Scanner;

    public class test {

    static int standardAnswer;

    public static void add(int addend1,int addend2){//加法
    System.out.print(addend1 + "+" + addend2 + "=");
    standardAnswer = addend1 + addend2;
    }
    public static void subtract(int minuend,int subtractor){//减法
    if(minuend<subtractor){//减数大于被减数时交换
    System.out.print(subtractor + "-" + minuend + "=");
    standardAnswer = subtractor - minuend;
    }
    else{
    System.out.print(minuend + "-" + subtractor + "=");
    standardAnswer = minuend - subtractor;
    }
    }
    public static void multiply(int multiplicator1,int multiplicator2){//乘法
    System.out.print(multiplicator1 + "×" + multiplicator2 + "=");
    standardAnswer = multiplicator1 * multiplicator2;
    }
    public static void divide(int dividend,int divisor){//除法
    if(dividend<divisor||divisor == 0){//被除数小于除数或除数为0时两个交换
    while(divisor%dividend>0){//有余数时进入循环
    dividend--;
    }
    System.out.print(divisor + "÷" + dividend + "=");
    standardAnswer = divisor / dividend;
    }
    else{
    while(divisor%dividend>0){//有余数时进入循环
    dividend--;
    }
    System.out.print(dividend + "÷" + divisor + "=");
    standardAnswer = dividend / divisor;
    }
    }

    public static void compared(int myAnswer,int standardAnswer){//判断是否为正确答案
    if(myAnswer == standardAnswer){
    System.out.println("做对啦!");
    }
    else{
    System.out.println("做错啦!再接再厉!");
    }
    }

    public static void main(String[] args) {
    // TODO Auto-generated method stub
    Random random = new Random();
    Scanner input=new Scanner(System.in);
    int myAnswer;

    System.out.print("请输入做题数量:");
    int questionCount = input.nextInt();
    System.out.println();

    for(int i = 0;i<questionCount;i++){
    int num1 = random.nextInt(101);//随机生成整数
    int num2 = random.nextInt(101);
    int index = random.nextInt(4);

    System.out.print((i+1)+".");//题号

    switch(index){
    case 0://+
    add(num1,num2);
    myAnswer = input.nextInt();
    compared(myAnswer,standardAnswer);
    break;
    case 1://-
    subtract(num1,num2);
    myAnswer = input.nextInt();
    compared(myAnswer,standardAnswer);
    break;
    case 2://*
    multiply(num1,num2);
    myAnswer = input.nextInt();
    compared(myAnswer,standardAnswer);
    break;
    case 3:// /
    divide(num1,num2);
    myAnswer = input.nextInt();
    compared(myAnswer,standardAnswer);
    break;
    default:
    break;
    }
    }
    System.out.print("已经做完"+questionCount+"题咯!");
    input.close();
    }

    }

    运行截图:

  • 相关阅读:
    【CF875E】Delivery Club 二分+线段树
    【CF316G3】Good Substrings 后缀自动机
    【BZOJ3413】匹配 离线+后缀树+树状数组
    【BZOJ2658】[Zjoi2012]小蓝的好友(mrx) 平衡树维护笛卡尔树+扫描线
    【BZOJ5133】[CodePlus2017年12月]白金元首与独舞 矩阵树定理
    【LOJ6254】最优卡组 堆(模拟搜索)
    面试问题总结
    Nginx基本配置
    Visual Studio Enterprise 2015下载 Update3
    .net 中生成二维码的组件
  • 原文地址:https://www.cnblogs.com/minduu/p/5368410.html
Copyright © 2011-2022 走看看