# Four Arithmetic program test

Source: Internet
Author: User

One: Foresight

Program is an essential step is the final maintenance and testing, so my program is small but also indispensable test, I test the content:

The order of the test data: 1. Number of topics, 2. Number of topics, 3. Print interval, 4. Maximum number of values; 5. There is no multiplication in the formula; 6. Plus or minus negative. 54

Test includes: Edge test, effect test, improper operation test, etc.

Two: Test

Test One:

1. Column Boundary test: 54,23,2,34,1,1

2. Recommended less than 7, the same way two lines can not be too large, then set the line spacing less than 5

Number of tests: 23, (8,-1,3), (7,2), 89,1,1

Test Two:

1. Addition and subtraction of the control: 34, 5, (8,2), 46,0,23

2. Add and subtract several pieces of control if the input non- 1.0 Number of errors, the same multiplication control, then the program to modify

Number of tests: 34,3,5,234, (34,2,1), (34,0)

Test Three:

1. Number of quiz: -23,3,2,1,1,1

2. Should control the number of the topic is positive, according to the actual situation to control the number of the question between 0 to the Road, the value range within the effective, modified as follows.

Number of tests: (324,-23,34), 2, 1, (2309,23), 1, (3,0)

Test four: Found in the divisor has O, then the new modification. if (n==3) {y=y+1;}, the final effect is as follows:

Three: Code

#include <iostream.h>
#include <stdlib.h>
void size (int x,int Y)
{

int d,n,a,i,j,b,c1,c2,z,e,x,y,m,h,t;

cout<< "" << "1. Number of topics (1~100):";
cin>>m;
while (m>100| | M<0)
{
cout<< ". Please enter the quantity correctly:";
cin>>m;

}
cout<<endl;

cout<< "<<" 2. Number of topics (1~7): ";
cin>>h;
while (h>7| | H<0)
{
cout<< ". Please enter the number of columns correctly:";
cin>>h;

}

cout<<endl;

cout<< "" << "3. Print interval ("): ";
cin>>t;
while (t>5| | T<0)
{
cout<< ". Please enter the interval correctly:";
cin>>t;

}
cout<<endl;

cout<< "" << "4. What is the maximum value:";
cin>>b;
while (b>500| | B<-500)
{
cout<< ". Please re-enter the maximum number (0~500):";
cin>>b;

}
cout<<endl;

cout<< "" << "5 Multiplication (with: 1; none: 0):";
cin>>a;
while (a!=1&&a!=0)
{
cout<<. Please re-enter the condition: ";
Cin>>a;

}
Cout<<endl;

cout<< "<<" 6. There are no negative numbers for the addition of: 1; none: 0): ";
cin>>z;
while (z!=1&&z!=0)
{
cout<<. Please re-enter the condition: ";
Cin>>z;

}
Cout<<endl;
cout<< "***********" << "The following are the topics" << "*****************" <<endl;

for (i=0;i<m;i++)

{
cout<<i+1<< ".";

X=rand ()%b;
Y=rand ()%b;
D=rand ();
E=rand ();

c1=d%2;
c2=e%2;

n=d%4;
------------------------------------have multiplication
switch (a)
{
Case 0:
if (n>1)
{
n=n-2;
}; Break
Case 1:break;
default:cout<< "Input multiplication control condition is wrong! ";

}

//------------------------------------plus minus negative

switch (z)
{
Case 0:break;
Case 1:x= ( -1) ^c1*x;

y= ( -1) ^c2*y;break;
default:cout<< "input plus and minus control conditions are wrong! ";
}

//----------------------------------control parentheses and output

if (n==3)
{
y=y+1;
}
switch (n)
{
Case 0:if (z>0)
{
cout<<x<< "+ <<" ("<<y<<") "<< "=" << "";
}
Else
{
cout<<x<< "+" <<Y<< "=" << "";
}; Break
Case 1:if (z>0)
{
cout<<x<< "-" << "(" <<y<< ")" << "=" << ";
}
Else
{
cout<<x<< "-" <<Y<< "=" << "";
}; Break
Case 2:cout<<x<< "*" <<Y<< "=" << "";
Case 3:cout<<x<< "/" <<Y<< "=" << "";

}

//----------------------------------------control number of columns, and two rows of interval

if ((i+1)%h==0)
{
for (j =0;j<t;j++)
{
Cout<<endl;
}
}
}
Cout<<endl;
}
//--------------------------main function
int main ()
{
int A;
int b;
cout<< "***********" << "Arithmetic topic customization:" << "************" <<endl<<endl;
Size (A, b);
return 0;
}

Four: summary

In this test found a lot of errors, small programs are so many errors, consider such a non-rigorous, large projects are more complex. So in the future programming, first enrich their knowledge, learn rigorous thinking, in this important is to do a good job of testing such a step.

Four Arithmetic program test

Related Keywords:

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.