Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

<p>plz i need help</p> <p>I have an output and input but the input is not compli

ID: 3631257 • Letter: #

Question

<p>plz i need help</p>
<p>I have an output and input but the input is not complite and i can't delet anything in the input i just have to complete it and add the missing thing</p>
<p>the input:</p>
<pre>int main()
{
char op;
int n;

cout &lt;&lt; "Welcome! ";
op = minu();

while (op != 'q')
{
switch(op)
{
case '1':
cout &lt;&lt; "Enter an integer: ";
cin &gt;&gt; n;
cout &lt;&lt; n &lt;&lt; "! = " &lt;&lt; fact(n) &lt;&lt; " ";
break;
case '2':
sum();
break;
case '3':
random();
break;
default:
cout &lt;&lt; "Wrong input! Try again! ";
}
op = minu();
}
cout &lt;&lt; "Goodbye! ";

return 0;
}
</pre>
<pre>=============================</pre>
<pre>the output:</pre>
<pre><pre>Welcome!

1. Factorial
2. Sum
3. Random Number Generator
Enter your choice, or 'q' to quit: 1

Enter an integer: 4
4! = 24

1. Factorial
2. Sum
3. Random Number Generator
Enter your choice, or 'q' to quit: 2

Enter an integer: 5
Sum(0,5) = 15

1. Factorial
2. Sum
3. Random Number Generator
Enter your choice, or 'q' to quit: 3

Enter two integers (Ex. 2 13): 5 8
How many random numbers do you want?
7
How many numbers per line?
3
xxxx6xxxx8xxxx7
xxxx5xxxx6xxxx5
xxxx7

1. Factorial
2. Sum
3. Random Number Generator
Enter your choice, or 'q' to quit: r

Wrong input! Try again!

1. Factorial
2. Sum
3. Random Number Generator
Enter your choice, or 'q' to quit: q

Goodbye!

Press any key to continue</pre>
</pre>

Explanation / Answer

please rate - thanks

try this

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
using namespace std;
char menu();
void factorial();
void sum();
void random();
int main()
{char choice;
srand(time(0));
for(; ;)
{choice=menu();
switch(choice)
   {case '1': factorial();
              break;
    case '2': sum();
              break;
    case '3': random();
              break;
    case 'q': cout<<"Goodbye! ";
              system("pause");
              return 0;
   }
}
}
char menu()
{char choice;
do
{
cout<<"1. Factorial ";
cout<<"2. Sum ";
cout<<"3. Random Number Generator ";
cout<<"Enter your choice, or 'q' to quit: 3 ";
cin>>choice;
if(choice>='1'&&choice<='3'||choice=='q'||choice=='Q')
      return choice;
cout<<"Wrong input! Try again! ";
}while(1);
}
void factorial()
{int i,n,nf=1;
cout<<"Enter an integer: ";
cin>>n;
for(i=2;i<=n;i++)
      nf*=i;
cout<<n<<"! = "<<nf<<endl<<endl;
}
void sum()
{int n,i,sum=0;
cout<<"Enter an integer: ";
cin>>n;
for(i=1;i<=n;i++)
   sum+=i;
cout<<"(0,"<<n<<") = "<<sum<<endl<<endl;
}
void random()
{int n, line=0,per,i,j,start,stop;
cout<<"Enter two integers (Ex. 2 13): ";
cin>>start>>stop;
cout<<"How many random numbers do you want? ";
cin>>n;
cout<<"How many numbers per line? ";
cin>>per;
for(i=0;i<n;i++)
   {cout<<setw(5)<<rand()%(stop-start+1)+start;
    line++;
    if(line==per)
        {cout<<endl;
        line=0;
        }
   }
cout<<endl<<endl;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote