Software Engineering Third job-------(Li Lisi Takanori)

Source: Internet
Author: User

Group members: Li Lisi Takanori topic:

Please write a "software" which can automatically generate the topic of primary arithmetic;

Allow the program to accept the user to enter the answer, and determine the right and wrong;

Finally, the total number of pairs/errors is given.

Requirements Analysis:
    • Basic functions

      Basic function point 1: realize primary school arithmetic;

      Basic function point 2: The program can accept the user input the answer, and judge the right and wrong;

Basic function point 3: Give the total number of pairs/errors.

Design
    • Design point 1: The programming environment of C language to achieve program code writing;
    • Design point 2: Randomly generate two numbers, respectively, using 1,2,3,4 to calculate the addition, subtraction, multiplication, division, through the calculation to determine the correctness of the calculation, and statistics of the number of correct and error.
1#include <stdio.h>2#include <stdlib.h>3#include <time.h>4 intMain ()5 {6     intX,y,all=0, r=0, e=0, result;7     CharZ;8     intM,n;9printf"Welcome to the Primary School calculator test! \ n");Tenprintf"Please enter a number from 1 to 4 (1 for addition, 2 for subtraction, 3 for multiplication, 4 for division), and end test when input is Q: \ n");  Onescanf"%d",&m); A Srand ((unsigned) time (NULL));  -      while((Z=getchar ())! ='Q')                -     { theall++; -X=rand ()% -; Y=rand ()% -; -         if(m==1) -         { +printf"%d+%d=", x, y);  -scanf"%d",&z); +printf"\ n"); A             if(x+y==z) atr++; -             Else -e++; -         } -         Else if(m==2) -         {                                       inprintf"%d-%d=", x, y); -scanf"%d",&z); to             if(x-y==z) +r++; -             Else thee++;  *         } $         Else if(m==3)Panax Notoginseng         {                                     -printf"%d*%d=", x, y); thescanf"%d",&z); +             if(x*y==z) Ar++; the             Else +e++; -         } $         Else if(m==4) $         {                              -printf"%d/%d=", x, y); -scanf"%d",&z); the             if(x/y==z) -r++;Wuyi             Else thee++;  -         } Wu         Else                                                         -printf"wrong input! \ n"); Aboutresult= -*r/All ;  $     } -printf"your score is:%d\n", result); -printf"you have finished%d title, the correct%d questions, the wrong%d questions \ n", all,r,e); -     if(result>= -) A     { +printf"The results are good, don't be proud Oh! \ n"); the     } -     Else $     { theprintf"performance needs to be improved, refueling, don't be discouraged Oh! \ n"); the     } the     return 0;  the}

Calculate add, subtract, multiply, divide:

#include <stdio.h>void main () {/* addition computes */int Jiafa (int a,int b,int c) {int c = a + B;return C;} /* Subtraction calculation */int jianfa (int a,int b,int c) {int c = A-b;return C;} /* Multiplication calculation */int chengfa (int a,int b,int c) {Float c = a * B;return C;} /* Division calculates */float chufa (int a,int b,int c) {if (b==0) {b=1;} float C = (float) A/(float) B;return c;}}

Place the function declaration in the header file:

1#include <stdio.h>2#include <stdio.h>3#include <stdio.h>4 5 intJiafa (intAintBintc);6 intJIANFA (intAintBintc);7 intCHENGFA (intAintBintc);8 floatChufa (intAintBintc);

Debug results:

Two-person cooperation steps:

1. Modify the original program to conform to the code style and the basic requirements of the design specification;

2. Two people to the original process of serious analysis, the basic ideas to solve the problem, the formulation of the plan;

3. Adopt the modular design idea, revise the previous code, encapsulate the calculation function;

4. Test the addition function.

Summarize:

1. Programming is a process of accumulation, as long as serious thinking, there will always be a solution to the problem;

2. The design of the program needs to meet the requirements of the subject, the primary arithmetic.

3. Specification of the format of the code, make the code easier to read, but also easy to check and modify the program.

4. Learned some simple methods of testing the basic functions of the program.

PSP Time Consuming:

Psp Personal Software Process Stage Time (h) Time (%)
Design Specific design 10 25
Coding Specific code 12 30
Code Review Code review 5 12.5
Test Testing (self-test, code modification) 8 20

Postmortem & Process

Improvement Plan

Summarize afterwards and propose process improvement plan 5 12.5

Software Engineering Third job-------(Li Lisi Takanori)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.