Title Description:
Starting from the "procedure" example of the first chapter of the Law of construction, take 20 minutes, like Chiu, to write a command line "software" that automatically generates arithmetic topics for primary schools to meet the following requirements:
In addition to integers, support the arithmetic of true fractions, the operation of true fractions, for example: 1/6 + 1/8 = 7/24
Operator is +,?, X,÷
and request to be able to handle the user input, and judge right and wrong, scoring statistics correct rate.
Requires a true score that can handle user input, such as 1/2, 5/12, etc.
Use the-n parameter to control the number of generated problems, such as executing the following command will generate 10 topics
Myapp.exe-n 10
Demand analysis
- 1. Support the arithmetic of integers and true fractions;
- 2, judge the user's answer is correct, and in the final display the correct rate;
- 3, can use parameters to control the number of generated problems.
Code description
- Provide the numerator property of judging the score, and find out its greatest common divisor and numerator.
Determine the correctness and error of the input answer and count it. Fractions are compared by string comparisons and integers are compared with = = to correct them.
Execution results
PSP Show
PSP2.1 |
Personal Software Process Stages |
Time (%) Senior Student (/hour) |
Time (%) (/hour) |
Planning |
Plan |
2h |
1.5h |
Estimate |
Estimate how long this task will take |
35h |
35h |
Analysis |
Demand analysis (including learning new technologies) |
1h |
1.5h |
Coding Standard |
Code specification |
1.5h |
1h |
Design |
Specific design |
3h |
3.5h |
Coding |
Specific code |
20h |
20h |
Test |
Test (self-test, modify code, commit changes) |
2h |
2h |
Reporting |
Report |
2h |
2h |
Code Link: https://coding.net/u/li111222zxc/p/Demo/attachment/Design summary
The process of programming first by the understanding to get the number and the beginning of judgment, the first is to complete the arithmetic of integers, start with a fixed number of topics, and then set the number of controllable questions, then the topic is set to a case in order to randomly generate the question (originally in accordance with the subtraction order), Then the subtraction of the score is finished and the numerator algorithm is designed and judged.
Java Arithmetic generator