Software Engineering (2018) Pairing 2nd Assignment

Primary four arithmetic automatic generator

1. The topic

Require:

  • Can automatically generate four arithmetic practice questions
  • The number of questions can be customized
  • User can choose operator
  • The maximum number set by the user (such as within ten, within one hundred, etc.)
  • The user chooses whether there are parentheses and whether there are decimals
  • The user selects the output method (such as output to a file, printer, etc.)
  • It is best to provide a graphical user interface (no)
    Second, the source code
    --------------- The
    code has been transmitted to coding -net

#include

char Operator()
{
char op;
int i;
i=rand()%4+1;
switch(i)
{
case 1: return '+';
case 2: return '-';
case 3: return 'x';
case 4: return '/';
}
}

void integer()
{
int x,y;
char op;
x=rand()%100+1;
y=rand()%100+1;
op=Operator();
if(op=='-')
while(x<y)
{
x=rand()%100+1;
y=rand()%100+1;
}
cout<<x<<op<<y<<"="<<endl;
}

void fraction()
{
int a,b,c,d;
a=rand()%100+1;
b=rand()%100+1;
c=rand()%100+1;
d=rand()%100+1;
char op;
while(a<=b||c<=d)
{
a=rand()%100+1;
b=rand()%100+1;
c=rand()%100+1;
d=rand()%100+1;
}
op=Operator();
if(op=='-')
while((bc-ad)<0)
{
a=rand()%100+1;
b=rand()%100+1;
c=rand()%100+1;
d=rand()%100+1;
}
cout<<b<<"/"<<a<<op<<d<<"/"<<c<<"="<<endl;
}

int main()
{
srand(time(0));
int i,n,m;
cout<<"Welcome!"<<endl;
cout<< "Please enter the question type"<<endl;
cout<< "1 .Four arithmetic operations on integers"<<endl;
cout<< "2.Four arithmetic operations on fractions"<

3. Summary

In this assignment, I obviously feel that my ability is very insufficient, and I have not completely completed the requirements of the topic. This is indeed my best effort. During the development process of our project, the steps of our project: detailed design, detailed design, coding, unit testing . In the process of project development, I also deeply realized that the detailed design has a clear guiding role in the development of a project. It can enable developers to have a specific understanding of the functions to be implemented by the project as a whole, and can reduce the number of delays in the development process. An unnecessary disconnect occurs. This training also made me deeply understand that it is very important to maintain a good relationship with teachers and classmates, both at work and in life. To do things, you must first be a human being, and you must understand the truth of being a human being. How to get along with others is the most basic problem in modern society. For a person like himself who is about to enter the society, there are many things to learn.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324552022&siteId=291194637