//Need to finish tonight--last day to turn in // Problem: stack around number is
ID: 3647128 • Letter: #
Question
//Need to finish tonight--last day to turn in// Problem: stack around number is corrupted
// Problem with the identification # lining up and displaying in the console correctly
// Validation the payRate---I need to remove cin.
//PLEASE HELP
Week 9 calculating employees pay roll.
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main ()
{
// Number of employeees
const int empID = 7;
int number[empID]= {5658845, 4520125, 7895122, 8777541,
8451277, 1302850, 7580489}; //Array of employees ID number
int numHours[empID]; // Display the hours worked by each employee
double payRate [empID]; // Display the pay rate earned by each employee
const int wages = 6;
double grossWages [empID];
int count;
// Inputting validation for employee ID number
for(count = 0; count < empID; count++)
{
cout << "Enter each employee ID number:" << (count + 1) << endl;
cin >> number[empID];
}
for(count = 0; count < empID; count++)
{
cout << " Enter the hours earned by each employee." << (count + 1) << endl;
cin >> numHours[count] ;
while (numHours[count] < 0)
{
cout << "Don not enter Non-negative hours:";
cin >> numHours[count];
}
cout << " Enter the employees pay rate." << endl;
cin >> number[count];
while (payRate [count] < 0)
{
cout << "Validate the pay rate:" << endl;
cin >> payRate[count];
}
grossWages[count] = payRate[count] * numHours[count];
}
// Display Employees ID and Total Wages in the consoles
cout << "Employees ID and Total Wages" << endl;
cout <<fixed << showpoint << setprecision(2); // Format for the array
for (count = 0; count < empID; count++)
{
cout << setw(12) << number[count]
<< setw( 9) << grossWages[count];
}
return 0;
}
Explanation / Answer
#include #include using namespace std; int main() { const int NUM_EMPLOYEES = 7; const int STRING_SIZE = 8; int hours[NUM_EMPLOYEES]; int payRate[NUM_EMPLOYEES]; float wages[NUM_EMPLOYEES]; coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.