Software Engineering Second Job

Source: Internet
Author: User

Topic:

Please write a "software" that can automatically generate primary arithmetic topics. 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.
Code implementation
1#include <stdio.h>2#include <stdlib.h>3#include <time.h>4 5 intMain ()6 {7     intX,y,all=0, r=0, e=0, result;8     CharZ;9     intM,n;Tenprintf"Welcome to the Primary School calculator test! \ n"); Oneprintf"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");  Ascanf"%d",&m); - Srand ((unsigned) time (NULL));  -         while((Z=getchar ())! ='Q')                the        { -all++; -X=rand ()% -; Y=rand ()% -; -            if(m==1) +            { -printf"%d+%d=", x, y);  +scanf"%d",&z); Aprintf"\ n"); at                if(x+y==z) r++; -                Else -e++; -            } -            Else if(m==2) -            {                                       inprintf"%d-%d=", x, y); -scanf"%d",&z); to                if(x-y==z) r++; +                Else -e++;  the            } *            Else if(m==3) $            {                                    Panax Notoginsengprintf"%d*%d=", x, y); -scanf"%d",&z); the                if(x*y==z) r++; +                Else Ae++; the            } +            Else if(m==4) -            {                              $printf"%d/%d=", x, y); $scanf"%d",&z); -                if(x/y==z) r++; -                Else thee++;  -            }Wuyi            Else                                                         theprintf"wrong input! \ n"); -result= -*r/All ;  Wu        } -printf"your score is:%d\n", result); Aboutprintf"you have finished%d title, the correct%d questions, the wrong%d questions \ n", all,r,e); $        if(result>= -){ -printf"The results are good, don't be proud Oh! \ n"); -        } -        Else{ Aprintf"performance needs to be improved, refueling, don't be discouraged Oh! \ n"); +        } the        return 0;  -}

Program

Addition:

Subtraction:

Multiplication:

Division:

Analysis and summary

PSP Time Consuming:

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

Postmortem & Process

Improvement Plan

Summarize afterwards and propose process improvement plan 5 10

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.

Software Engineering Second Job

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.