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

// Debug File #4 #include <iostream> using namespace std; int main() { //declare

ID: 3879033 • Letter: #

Question

// Debug File #4
#include <iostream>
using namespace std;

int main()
{
//declare variables
int hoursWorked, payRate, pay;

// Get the number of hours worked.
cout << "How many hours did you work? ";
cin >> hoursWorked;

// Get the hourly pay rate.
cout << "How much do you get paid per hour? ";
cin >> payRate;

// Calculate the pay.
pay = hoursWorked * payRate;

cout<< "Hours = " << hoursWorked << setw(7);

cout << "Pay = "<< payRate;

cout setprecision(14)<< showpoint<<fixed;
// Display the pay.
cout << set(2)<< "You have earned $" << pay << endl;
system ("pause");
return 0;

Explanation / Answer

The code is

#include <iostream>
#include <iomanip>
#include <cstdlib>
using namespace std;

int main()
{
//declare variables
int hoursWorked, payRate, pay;

// Get the number of hours worked.
cout << "How many hours did you work? ";
cin >> hoursWorked;

// Get the hourly pay rate.
cout << " How much do you get paid per hour? ";
cin >> payRate;

// Calculate the pay.
pay = hoursWorked * payRate;

cout<< " Hours = " << hoursWorked << setw(7);

cout << " Pay = "<< payRate;

cout<<setprecision(14)<< showpoint<<fixed;
// Display the pay.
cout << setw(2)<< " You have earned $" << pay << endl;
system ("pause");
return 0;

}

The output is

How many hours did you work? 10

How much do you get paid per hour? 125

Hours = 10
Pay = 125
You have earned $1250
Press any key to continue . . .