183
社区成员
The Link Your Class | https://bbs.csdn.net/forums/MUEE308FZ?category=0 |
---|---|
The Link of Requirement of This Assignment | https://bbs.csdn.net/topics/601188617 |
MU STU ID and FZU STU ID | 19105592 & 831902115 |
Teammate1's MU STU ID and FZU STU ID | 19105932 & 831902104 |
Teammate2's MU STU ID and FZU STU ID | 19105576 & 831902202 |
Teammate3's MU STU ID and FZU STU ID | 19104031 & 831902114 |
Teammate4's MU STU ID and FZU STU ID | 19103158 & 831902116 |
GitHub link | https://github.com/1252845841hhAs/Lab05-Snowed-in-Taipei- |
PSP | Personal Software Process Stage | Estimated Time (minutes) | Actual Time (minutes) |
---|---|---|---|
Planning | Make a plan | 10 | 10 |
Estimate | Estimate how long the task will take | 160 | 175 |
Development | The development of | 7 | 8 |
Analysis | Requirements analysis (including learning new technology) | 12 | 14 |
Design Spec | Generate design documents | 6 | 6 |
Design Review | Design review | 3 | 4 |
Coding Standard | Code specifications (develop appropriate specifications for current development) | 3 | 3 |
Design | Specific design | 40 | 42 |
Coding | Specific coding | 120 | 130 |
Code Review | Code review | 7 | 8 |
Test | Test (self-test, modify code, commit changes) | 10 | 20 |
Reporting | Report | 10 | 10 |
Test | Test report | - | - |
Postmortem&Process Improvement | Summarize afterwards and propose process improvement plan | 6 | 7 |
Summary | - | 160 | 175 |
hours | new code(line) | Cumulative code (line) | Important growth |
---|---|---|---|
0.5 | 0 | 0 | Analyze the experimental project, establish the general framework, the team leader to the division of labor |
1 | 150 | 150 | Use if, switch, and for statements |
0.5 | 20 | 20 | How to generate random numbers |
0.5 | 10 | 10 | How to keep two decimal places |
1 | 0 | 0 | Program result testing and modification & Blog Writing |
Team Members | MU ID | The Division Of Responsibilities |
---|---|---|
Yue Zhuo | 19105592 | Grade 1 to grade 2: addition and subtraction of integers within 100 and github |
Jinhan Lin | 19103158 | Grade 1 to grade 2: addition and subtraction of integers within 100 and github |
Chuan He | 19104031 | Grades 3 to 4: addition, subtraction, multiplication and division of integers and CSDN |
Yanqi Fan | 19105932 | Grades 3 to 4: addition, subtraction, multiplication and division of integers and CSDN |
Yaxing Li | 19105576 | Grades 5 to 6: addition, subtraction, multiplication and division including decimals |
C++
Firstly, in the design process, we found that multiple layers of identification input and different operations are required this time, which is different from the single or single-layer input and judgment we faced before.
Secondly, since the use of random numbers is involved, we are not familiar with the call of such functions. Therefore, we have fully understood the use of Rand functions through consulting materials. At the same time, we note that random numbers can also help us generate random operators. Since Grades 3-6 need to calculate multiplication and division, we use if statements to represent "+" "-" "*" "/" by generating four numbers: 0, 1, 2 and 3. After running the program, we found that there are some small mathematical problems in the program. For example, negative numbers and divisor 0 may occur during subtraction. We also realized through the code that there will be no questions with negative answers and divisor 0.
#include <time.h>
srand(time(NULL));
int a=rand()%100;
int b=rand()%100;
Thirdly, when generating decimals, sometimes the answer is infinite decimals, and the result we need is to retain two decimal places. After the brainstorming of team members, we use the following methods to realize the operation of retaining two decimal places. We first add 0.005 to the obtained data, and this step realizes the rounding of the two decimal places after the decimal point, Then multiply the number by 100 to get an integer of type int, and then divide by 100 to get a floating-point number in the form of float, that is, the answer we need.
double a=(double)(rand())/1000;
double b=(double)(rand())/1000;
a = ((float)((int)((a+0.005)*100))/100);
b = ((float)((int)((b+0.005)*100))/100);
Finally, in order to accomplish the main function, we use the random numbers and get the results. Then, we compare the result to the answer that typed in. We divided the whole score, which is 100, by the number of questions. If the answer is true, we add the score. If wrong, we lose the score. At the end, we calculate the scores we gain, and show it on the screen.
for(size; size>0; size--) {
int type=rand()%2;
if(type==0) {
int a=rand()%100;
int b=rand()%100;
int result;
result=a+b;
cout<<a;
cout<<"+";
cout<<b;
cout<<"=";
int student;
cin>>student;
if(student==result) {
source=source+source1;
i++;
}
}
We used C + + to complete today's laboratory. Through this laboratory, we skillfully mastered the generation and use of random numbers. By realizing some relevant mathematical functions, we improved our ability to convert our ideas into actual code to realize the functions we need.