1. Write C++ statements that produce the following output:
Name: //output the value of the variable name
Pay Rate: $ //output the value of the variable rate
Hours Worked: //output the value of the variable
//hoursWorked
Salary: $ //output the value of the variable wages
For example, if the value of name is "Rainbow" and hoursWorked is
45.50, then the output is:
Name: Rainbow
Pay Rate: $12.50
Hours Worked: 45.50
Salary: $568.75
#include<iostream>
using namespace std;
int main()
{
string name;
double rate, hoursWorked, wages;
cout<<"Please, enter the name of the worker: ";
cin>>name;
cout<<"Please, enter pay rate for the worker: ";
cin>>rate;
cout<<"Please, enter hours worked by worker: ";
cin>>hoursWorked;
wages=rate*hoursWorked;
cout<<"\nName: "<<name
<<"\nPay Rate: $"<<rate
<<"\nHours Worked: "<<hoursWorked
<<"\nSalary: $"<<wages;
}
Comments
Leave a comment