First, the needs analysis
1.1 target user needs analysis
The four operations are an important part of school mathematics, but also learn the basic knowledge of each other; the use of auto-generated title four operations program may further training pupils computing capacity, improve computing power and reduce the workload of teachers and parents out of question.
1.2 Functional Requirements Analysis
Small (1) preparation of test system to learn the four arithmetic operations, required to complete within two digits (including two-digit) addition, subtraction, multiplication, addition to four arithmetic operations.
(2) Title Number difficult (multiplication and division is included, contains a negative number), values of the operands can be customized.
(3) calculating notepad stored title can be generated.
Second, the functional design
2.1 Basic functions
(1) automatically generates four arithmetic operation of Equation 2 number less than 10 100 (+ - * /), the calculation result is within 100.
(2) discarding duplicates equation.
Number (3) Title can be customized (in the range of 1 to 1,000).
(4) parameters can be controlled
Whether to include multiplication and division.
Operand controllable range of values (e.g., within an operand within 10 or 100).
Whether operands containing negative.
(5) generated the title stored in the external file operation in result.txt.
2.2 extensions
(1) determine whether cross-border or input error, if an error occurs, remind and enter again.
(2) whether the calculation result.
Third, the design and implementation
3.1 Language and Tools
Using the C language and the use of C-Free 5 program code.
3.2 Implementation
This program uses only four arithmetic functions of a master function. All the functions of a main function in vivo (mode needs to be improved).
Fourth, the test run
4.1 to automatically generate the four arithmetic operations of equation 2 operands within 100 10 (+ - * /)
Enter the desired titled 10, and operand 2 ( run successfully ).
4.2 Excluding repeat formula
First set the number of items entered larger, multiplication and division control, negative calculation variables, then a range of values is provided within a range which can be calculated (test 1 and 2), all to appear non-repeating formula ( run successfully ).
4.3 the number of items can be customized
Title number is set to 28 and 15, respectively, other control parameters constant ( run successfully ).
4.4 may control parameters
In particular the number of items, is included multiplication and division, the controllable range of values of the operands (e.g., 10 or operand within less than 100), whether or not containing a negative operand can execute ( run successfully ).
4.5 generating operation to an external file title stored in result.txt
Run successfully .
4.6 determine whether the input is out of range or an error, if error, remind and enter again
The number of questions, the results had no effect (whether to join after multiplication and division, whether to join the negative, whether the wrong answer deliberately or out of bounds, the program will remind again and you can enter and run successfully ).
4.7 whether to display the result of the operation
Run successfully .
V. snippet
5.1 abnormal and control inputs
the while ( . 1 ) { the printf ( " Please enter the number of items that you need (within the range of 100 ~ 10): \ n- " ); Scanf ( " % D " , & judge_1); IF (judge_1> 100 || judge_1 < 10 ) the printf ( " \ n-input error, please re-enter \ n-\ n- " ); the else BREAK ; } the while ( 1 ) { the printf ( " whether addition of multiplication and division (1: 0: no): \ n- " ); Scanf ( " % D " ,&judge_2); IF ! (judge_2 = . 1 ! && judge_2 = 0 ) the printf ( " \ n-input error, please re-enter \ n-\ n- " ); the else BREAK ; } the while ( . 1 ) { the printf ( " Please input operand values range (eg: 10 or 100): \ n " ); Scanf ( " % D " , & judge_3); IF (judge_3> 1000 || judge_3 <= 0 ) the printf ( " \ n input error, please re-enter \ n \ the n- " ); the else BREAK; } The while ( 1 ) { the printf ( " whether negative calculation (1: 0: no): \ n- " ); Scanf ( " % D " , & judge_4); IF (! Judge_4 = 1 ! && judge_4 = 0 ) printf ( " \ the n-input errors, please re-enter \ the n-\ the n- " ); the else BREAK ; } the while ( 1 ) { printf ( " need to answer (1: 0: No): \ the n- " ); scanf ( "%d", & Judge_5); IF (judge_5 =! . 1 && judge_5 =! 0 ) the printf ( " \ n-input error, please re-enter \ n-\ n- " ); the else BREAK ; }
5.2 discarding duplicates
int t=0; fg_1[i]=figure_1; law[i]=s; fg_2[i]=figure_2; for(a=i;a>0;a--) { if((fg_1[i]==fg_1[a-1])&&(law[i]==law[a-1])&&(fg_2[i]==fg_2[a-1])) { t=1; } }
5.3 whether negative
IF (judge_4 == 0 ) { figure_1 = RAND () +% judge_3 . 1 ; // positive operation of the random number. 1 figure_2 = RAND () +% judge_3 . 1 ; // positive random operand 2 } the else IF (judge_4 == . 1 ) { figure_1 = RAND ()% ( 2 * judge_3 + . 1 ) -judge_3; // negative random number of operations. 1 figure_2 = RAND ()% ( 2 * judge_3 + . 1 ) -judge_3; // negative random number operation 2 }
If required 5.4 multiplication and division
RAND = T ()% al; // randomly calculated al assignment in the input, input 0 (NO) is assigned 2 (without multiplication and division); Input 1 (a) is assigned 4 (including multiplication and division) IF (T == 0 ) // adder { Result = figure_1 + figure_2; S = ' + ' ; } the else IF (T == . 1 ) // subtraction { Result = figure_1- figure_2; S = ' - ' ; } the else IF (T = = 2 ) // multiplication { result=figure_1*figure_2; s='*'; } else if(t==3)//除法 { result=figure_1/figure_2; s='/'; }
5.5 need to show whether the answers stored in an external file
IF (judge_5 == . 1 ) // determine whether to answer { IF (figure_2 < 0 ) // second number is the negative bracketed { the printf ( " % d of questions:% d% c (% d ) =% d \ n- " , I + . 1 , figure_1, S, figure_2, Result); fprintf (FP, " % d of questions:% d% C (% d) =% d \ n- " , I + . 1 , figure_1, S, figure_2, Result); // file stored in the external } the else { the printf ( " % d of questions:% d% d% C =% d \ n- " , I + . 1,figure_1,s,figure_2,result); fprintf(fp,"第%d题:%d%c%d=%d\n",i+1,figure_1,s,figure_2,result); } } else { if(figure_2<0){ printf("第%d题:%d%c(%d)=\n",i+1,figure_1,s,figure_2); fprintf(fp,"第%d题:%d%c(%d)=\n",i+1,figure_1,s,figure_2); } else { printf("第%d题:%d%c%d=\n",i+1,figure_1,s,figure_2); fprintf(fp,"第%d题:%d%c%d=\n",i+1,figure_1,s,figure_2); } } }
VI Summary
6.1 Project Summary
In the development of this project, and no other function other than the primary function, the function is implemented in a main function implemented, resulting in no reflected modular code. But in the function or in line with the modular principle, the following is a functional block diagram of my program.
First, I program must have the required number of the subject, determining the amount to be able to perform a range of operands, whether to include multiplication and division, and the like contain a negative determination function, and each of the operational problems generated into the specified array inside, then culling repeat function. After specifying the desired number of the title is reached, generating the four operations with the two operands. Finally, it is determined whether the user needs to answer play, and the resulting four arithmetic operations are stored in the external file resul.txt.
6.2 self-summary
The job made me realize my own shortcomings in program design, especially in the design function did not reflect the modularity, there are more jumbled in the code, well-organized is not clear and so on.
Seven, PSP
PSP2.1 |
SUMMARY |
Plan time (min) required to complete a total of |
The actual time required for completion (min) |
Planning |
plan |
10 |
8 |
· Estimate |
· Estimate how much time this task requires, and planning generally work steps |
10 |
8 |
Development |
Develop |
165 |
190 |
·· Analysis |
Needs analysis (including learning new technologies) |
10 |
15 |
· Design Spec |
Generate design documents |
20 |
30 |
· Design Review |
· Design Review (and his colleagues reviewed the design documents) |
10 |
8 |
· Coding Standard |
Code specifications (development of appropriate norms for the current development) |
5 |
3 |
· Design |
Specific design |
10 |
14 |
· Coding |
Specific coding |
60 |
80 |
· Code Review |
· Code Review |
20 |
20 |
· Test |
· Test (self-test, modify the code, submit modifications) |
30 |
20 |
Reporting |
report |
9 |
6 |
· Test Report |
· testing report |
3 |
2 |
· Size Measurement |
Computing workload |
3 |
1 |
· Postmortem & Process Improvement Plan |
· Hindsight, and propose process improvement plan |
3 |
3
|