Question

# (Use C++ language) Create a program, named threeTypesLoops.cpp, that does the following; 1. Uses a For...

(Use C++ language)

Create a program, named threeTypesLoops.cpp, that does the following;

1. Uses a For Loop that asks for a number between 1 and 10;

• Will double the number each time through the loop and display the answer.
• Will run five times, so the number will have been doubled five times, and the answer displayed five times.
• After the loop, display a message saying 'It's done!'.

2. Uses a While Loop;

• Ask the user to input a friend's name.
• Display the sentence: <name> is a friend of yours.
• Have the loop run three times.

3. Uses a Do While Loop:

• Ask the user to input the number of hours they worked in a week.
• Compute their gross pay (before taxes) by multiplying their hours times the constant float RATE of 15.50.
• Compute their taxes by multiplying their gross pay times the constant float TAX_RATE of .2.
• Compute their net pay by subtracting their taxes from their gross pay.
• Display their gross pay, taxes, and net pay in separate sentences, describing what each represents.
• Ask the user if they have another week of hours. If they enter something other than 'y', exit the loop, and display "Have a nice day!".

Code is Given Below:

=======================

#include <iostream>
#define RATE 15.50
#define TAX_RATE .2
using namespace std;
int main()
{ int num;
//part 1
for(int i=0;i<5;i++){
//asking user for number
cout<<"Enter a number between 1 and 10 : ";
cin>>num;
num=num*2;
//display result
}

cout<<"It\'s done!"<<endl;
int j=0;
//part 2
string name;
while(j<3){
//asking user for name
cout<<"Enter your friend\'s name : ";
cin>>name;
//display result
cout<<name<<" is a friend of yours"<<endl;
j++;}
//part 3
int hours;
char option;
float grossPay,tax,netPay;
do{
//asking user for input
cout<<"Enter number of hours you worked in a week : ";
cin>>hours;
//calculating results
grossPay=hours*RATE;
tax=grossPay*TAX_RATE;
netPay=grossPay-tax;
//display data
cout<<"Gross Pay : "<<grossPay<<endl;
cout<<"Tax : "<<tax<<endl;
cout<<"Net Pay : "<<netPay<<endl;
cout<<"Have another week of hour (y/n): ";
cin>>option;}
while(option=='y' || option=='Y');
return 0;}

Output:

---------------

Code Snapshot:

==================

#### Earn Coins

Coins can be redeemed for fabulous gifts.