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, demand 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 of integers want x, Y.

3, the software can manually input the results of the operation, the user to determine the correct answer to the wrong.

4, the correct answer to the user can be counted on the wrong number.

Third, design

For pupils to do the number of questions and correct and wrong number of questions can be counted to help users to count the answer.

Four, the code

#include"stdio.h"#include"windows.h"intright=0, wrong=0;voidJia () {intx, Y, Z X=rand ()% -; Y=rand ()% -; printf ("Please enter your answer:%d+%d=", x, y); scanf ("%d",&z); if(x+y!=z) {printf ("Answer error!\n"); Wrong++; }    Else{printf ("Answer right!\n"); Right++; } }voidJian () {intx, Y, Z X=rand ()% -; Y=rand ()% -; printf ("Please enter your answer:%d-%d=", x, y); scanf ("%d",&z); if(x-y!=z) {printf ("Answer error!\n"); wrong++; }     Else{printf ("Answer right!\n"); Right++; } }voidCheng () {intx, Y, Z X=rand ()% -; Y=rand ()% -; printf ("Please enter your answer:%d*%d=", x, y); scanf ("%d",&z); if(x*y!=z) {printf ("Answer error!\n"); Wrong++; }     Else{printf ("Answer right!\n"); Right++; } }voidChu () {intx, Y, Z X=rand ()% -; Y=rand ()% -+1; printf ("Please enter your answer:%d/%d=", x, y); scanf ("%d",&z); if(x/y!=z) {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");}

Five, run the code

Six, PSP timing

Vii. Summary

For this assignment, I still have some problems, for example, is not very familiar with writing code, plus the PSP timing is not very understanding. But the biggest gain of my homework is a little interest in software engineering.

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.