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.

A: Basic requirements

1: Select the interface design, select Add, subtract, multiply, divide the operation.

2: The system randomly generates two numbers within 100.

3: During the exercise, the user input results from the keyboard, correct and error are prompted, press 6, display the total number of questions and correct number.

Second: Demand analysis

The preparation of primary school arithmetic test system, requires the completion of two-digit addition, subtraction, multiplication, in addition to arithmetic. Can be based on user input to choose the type of operation, the user input answers can be judged correct, after a test, the user can decide whether to continue the next operation.

Three: Design

1: Define variable i,j,a,b,m where I is the correct number of questions, J indicates the number of answers to the wrong question, a, b indicates the number randomly generated, and m receives the result of the operation from the keyboard input.

2: Define add, subtract, multiply, divide the sub function, error and correct all have hints respectively.

3: The main function uses switch to implement user input to select the type of operation, and output the number of questions and correct number of questions. Four: Code implementation

#include <stdio.h> #include <stdlib.h> #include <time.h>int i=0,j=0;void Jia () {int A,b,m;srand (    NULL)); A=1+rand ()%100;    B=1+rand ()%100;    printf ("%d\n", a);    printf ("%d\n", b);    printf ("a+b=?\n");p rintf ("Please enter the result of the operation \ n"); scanf ("%d", &m), if (m==a+b) {printf ("Congratulations on your correct answer \ n"); i++;} else{printf ("You have the wrong answer \ n"); J + +;}}    void Jian () {int A,b,m;srand (time (NULL)); A=1+rand ()%100;    B=1+rand ()%100;if (a<b) {int t=0;t=a;a=b;b=t;}    printf ("%d\n", a);    printf ("%d\n", b);    printf ("a-b=?\n");p rintf ("Please enter the result of the operation \ n"); scanf ("%d", &m), if (m==a-b) {printf ("Congratulations on your correct answer \ n"); i++;} else{printf ("You have the wrong answer \ n"); J + +;}}    void Cheng () {int A,b,m;srand (time (NULL)); A=1+rand ()%20;    B=1+rand ()%20;    printf ("%d\n", a);    printf ("%d\n", b);    printf ("a*b=?\n");p rintf ("Please enter the result of the operation \ n"); scanf ("%d", &m), if (m==a*b) {printf ("Congratulations on your correct answer \ n"); i++;}        else{printf ("You have the wrong answer \ n"); j + +;}}    void Chu () {int A,b,m;srand (time (NULL));    A=1+rand ()%100; B=1+rand ()%100;if (b==0) {B=1+rand ()%100;} IF (a<b) {int t=0;t=a;a=b;b=t;}        while (a%b!=0) {A=1+rand ()%100;    B=1+rand ()%100;}    printf ("%d\n", a);    printf ("%d\n", b);    printf ("a/b=?\n");p rintf ("Please enter the result of the operation \ n"); scanf ("%d", &m), if (m==a/b) {printf ("Congratulations on your correct answer \ n"); i++;}        else{printf ("You have the wrong answer \ n"); j + +;}}
int main () {int M,n=0;while (1) {printf ("1. addition operation \ n");p rintf ("2. Subtraction operation \ n");p rintf ("3. multiplication \ n");p rintf ("4. Division operation \ n"); printf ("Please select"); scanf ("%d", &m), switch (m) {case 1:jia (); break;case 2:jian (); break;case 3:cheng (); Break;case 4:chu ( ); break;} printf ("5. Please re-select \ n");p rintf ("6. End \ n"); scanf ("%d", &n); if (n==6) break;} printf ("You answer the total number%d and the correct number of%d\n", i+j,i); return 0;}

V: System Testing

(1) Addition computing interface, including the overall book and correct number of

(2) Subtraction operator Interface (3) multiplication Interface (4) Division Operation VI: PSP time-consuming statistics
Serial number Psp Take Percent (%)
1 Demand analysis 18 23%
2 Design 20 25.6
3 Code implementation 30 38.5%
4 Test 5 6.4%
5 Analysis and summary 5 6.4%

VII: Analysis and summary

First see the topic, specific how to write, I almost do not understand. Ask the teacher and classmates to understand the problem. Students ' communication can be completed

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.