Question: Your program doesn't match the requirement. The program is taking any input and irrespective of the input it is printing values in three sets which
Your program doesn't match the requirement. The program is taking any input and irrespective of the input it is printing values in three sets which doesn't match the requirement. Please recheck the documentation guide and redo the program. There are three specific methods shown in the documentation guide for you to approach the program. You have also used srand() wrong in the program. I would suggest you take a look at the documentation again and use the functions as the below-mentioned example.
num = rand() % 10 + 1;\"
This was the feedback on my program please fix it/re-write to follow the \"requirements\". I will provide my program and the programming assignment. ( I also attempted the extra credit)
#include
#include
usingnamespacestd;
intmain()
{
srand(17);
intmax1=25,max2=50,max3=250;
intdis1=5,dis2=6,dis3=7;
inteven=0,odd=0,zero=0;
charch;
// first set
// generate the size of first set randomly
cout\"*****>
cout\"e)ven o)dd z)ero \";>
cout\"what>
cin>>ch; // for extra credit
intsize=rand()%max1+1;
cout\"there>\">
for(inti=1;i
{
// generate number to print
intnum=rand();
if(num%2==0) // for extra credit if number is even
even++;
else
odd++;
if(num==0) // if zero
zero++;
cout\">
if(i%dis1==0) // used to break the line
cout
}
cout
if(ch=='E') // for extra credit if even
cout\"there>\">
elseif(ch=='O') // for extra credit if odd
cout\"there>\">
elseif(ch=='Z') // for extra credit if zero
cout\"there>\">
even=0;
odd=0;
zero=0;
// generate the size of second set randomly
size=rand()%max2+1;
cout\"there>\">
inti=1;
while(i
{
// generate number to print
intnum=rand();
if(num%2==0) // for extra credit
even++;
else
odd++;
if(num==0)
zero++;
cout\">
if(i%dis2==0) // used to break the line
cout
i++;
}
cout
if(ch=='E') // for extra credit if even
cout\"there>\">
elseif(ch=='O') // for extra credit if odd
cout\"there>\">
elseif(ch=='Z') // for extra credit if zero
cout\"there>\">
even=0;
odd=0;
zero=0;
// generate the size of third set randomly
size=rand()%max3+1;
cout\"there>\">
i=1;
do
{
// generate number to print
intnum=rand();
if(num%2==0) // for extra credit
even++;
else
odd++;
if(num==0)
zero++;
cout\">
if(i%dis3==0) // used to break the line
cout
i++;
}while(i
cout
if(ch=='E') // for extra credit if even
cout\"there>\">
elseif(ch=='O') // for extra credit if odd
cout\"there>\">
elseif(ch=='Z') // for extra credit if zero
cout\"there>\">
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
