I do my work on a mac but have some trouble running it at times. How would this
ID: 3845738 • Letter: I
Question
I do my work on a mac but have some trouble running it at times. How would this look.
6 int main 8 Gout PUT YOUR NAME HERE. An Gout "InActivity 1 In Change the following do-while loop to a while loop 10 11 int inputNum; 12 do 13 Agut Enter a number (or 0 to quit) 14 sin inputNum; 15 while (input Num 0) 16 Gout "InActivity 2 In 17 18 Change the following while loop to a do-while loop 19 char doAgain 'y'; 20 while (do Again 'Y' l I doAgain 'y') Gout Do you want to loop again (y/n) 21 22 in doAgain; 23 24 25 Gout "InActivity 3 In An 26 Change the following while loop to a for loop int count 0; 27 28 while (count++ 5) 29 cout Count is count endl; 30 31 Rout In Activity 4 In 32 Change the following for loop to a while loop for (int x 5; x 0; x--) 33 Aout x seconds to go. In 34 35 36 Gout In Activity 5 In Make the following changes to the code below that uses nested loops 37 38 1. The code is supposed to print 3 lines with a and 5 stars on 39 each line, but it contains a logic error. Find and fix the error 2 Then revise the code to follow each with just 4 stars, like this 40 41 42 43 3. Change the two loop control variable names to be more descriptive. 44 for (int i 1 i 3; it 45 46 Gout. for (int j 1; jExplanation / Answer
#include <iostream>
using namespace std;
int main()
{
std::cout<<"PUT YOUR NAME HERE. ";
std::cout<<" Activity 1 ============= ";
int inputNum=1;
while(inputNum!=0)
{
std::cout<<" Enter a number (or 0 to quit):";
cin>> inputNum;
}
std::cout<<" Activity 2 ============= ";
char doAgain='Y';
do
{
std::cout<< "Do you want to loop again ? (Y/N)";
cin>> doAgain;
}while(doAgain=='Y'||doAgain=='y');
std::cout<<" Activity 3 ============= ";
for (int count=0;count<5;count++)
{
std::cout<<" count is "<<count<< std::endl;
}
std::cout<<" Activity 4 ============= ";
int x=5;
while (x-- > 0)
std::cout<<x<<" seconds to go. ";
std::cout<<" Activity 5 ============= ";
for(int loop3times=1;loop3times<=3;loop3times++)
{
std::cout<<'$';
for(int loop5times=1;loop5times<5;loop5times++)
std::cout<<'*';
std::cout<< std::endl;
}
std::cout<< std::endl;
return 0;
}
===============================================================================
Sample Output
PUT YOUR NAME HERE.
Activity 1
=============
Enter a number (or 0 to quit):1
Enter a number (or 0 to quit):2
Enter a number (or 0 to quit):89
Enter a number (or 0 to quit):569
Enter a number (or 0 to quit):0
Activity 2
=============
Do you want to loop again ? (Y/N)y
Do you want to loop again ? (Y/N)y
Do you want to loop again ? (Y/N)y
Do you want to loop again ? (Y/N)n
Activity 3
=============
count is 0
count is 1
count is 2
count is 3
count is 4
Activity 4
=============
4 seconds to go.
3 seconds to go.
2 seconds to go.
1 seconds to go.
0 seconds to go.
Activity 5
=============
$****
$****
$****
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.