Software Engineering (second job)

Source: Internet
Author: User

First, the 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.

Second, analysis

1, this software can choose the required arithmetic symbol, namely add, subtract, multiply, divide.

2, for the user to select the operation symbol can automatically generate two random numbers.

3, the user manually input the results of the operation, the software can determine the correctness of the user's answer.

4, the user answer to the correct or not can be counted.

Third, the Code
#include"stdio.h"#include"windows.h"intright=0, wrong=0;voidJia () {intA,b,c; A=rand ()% -; b=rand ()% -; printf ("Please enter your answer:%d+%d=", A, b); scanf ("%d",&c); if(a+b!=c) {printf ("Answer error!\n"); Wrong++; }    Else{printf ("Answer right!\n"); Right++; } }voidJian () {intA,b,c; A=rand ()% -; b=rand ()% -; printf ("Please enter your answer:%d-%d=", A, b); scanf ("%d",&c); if(a-b!=c) {printf ("Answer error!\n"); wrong++; }     Else{printf ("Answer right!\n"); Right++; } }voidCheng () {intA,b,c; A=rand ()% -; b=rand ()% -; printf ("Please enter your answer:%d*%d=", A, b); scanf ("%d",&c); if(a*b!=c) {printf ("Answer error!\n"); Wrong++; }     Else{printf ("Answer right!\n"); Right++; } }voidChu () {intA,b,c; A=rand ()% -; b=rand ()% -; printf ("Please enter your answer:%d/%d=", A, b); scanf ("%d",&c); if(a/b!=c) {printf ("Answer error!\n"); Wrong++; }    Else{printf ("Answer right!\n"); Right++; }}voidMain () {intchoise,sum=0; printf ("\n\n\t\t Welcome to my C-Language four OP program system!\n"); System ("Pause"); System ("CLS");  while(1) {printf ("\n\n\t\t\t Please select the calculation symbol: \ n addition (input 1) \ t subtraction (input 2) \ t multiplication (input 3) \ t Division (input 4) \ n"); if(sum==0) scanf ("%d",&choise); Switch(choise) { Case 1: Jia (); Break;  Case 2: Jian (); Break;  Case 3: Cheng (); Break;  Case 4: Chu (); Break; } printf ("Please select: \ t continue (input 1) \ t Re (enter 2) \ t to exit (enter 3) \ n"); scanf ("%d",&sum); if(sum==1) sum=1; if(sum==2) sum=0; if(sum==3) Break; } printf ("you've done%d questions, correct%d, error%d!\n", right+Wrong,right,wrong); System ("Pause");}

Iv. Effect of the procedure



Five, PSP time-consuming statistics

Vi. Summary

This assignment is mainly based on design and analysis, let me understand the hardships of software development process. Through a short period of time, simple design of the above software, the above software can basically complete the arithmetic problem of pupils. For example, you can actively select the desired arithmetic symbol, that is, add, subtract, multiply, divide, for the user to select the operation symbol can automatically generate two random numbers, the user can manually enter the results of the operation, to determine the number of errors and statistics. But it is not hard to see that there are some flaws. For example, the two random numbers produced by this question are integers, but in the case of division, the result is usually a decimal (fractional), in which case the software automates the computed result to an integer, which is inconsistent with the fact. So, this is one of the problems of this software, and time will be gradually improved.

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.