Question

Write, compile, and test a C++ program that uses a loop to calculate and display each...

Write, compile, and test a C++ program that uses a loop to calculate and display each employee’s weekly pay and the accumulated total pay for the company. The program will first ask the user for the number of employees. It will then ask for the number of hours and rate of pay for each employee and display the calculated pay for each employee. EXAMPLE RUN (user input appears in blue and bold): Enter number of employees: 3 Hours: 5 Rate (in dollars): 4.00 Pay is $20.00 Hours: 6 Rate (in dollars): 5.00 Pay is $30.00 Hours: 1.5 Rate (in dollars): 10.00 Pay is $15.00 All employees processed. Total payroll is $65.00 Format Manipulators: setw ( ), setprecision ( ), setiosflags(ios::showpoint), setiosflags(ios::fixed), setiosflags(ios::scientific), setiosflags(ios::left), setiosflags(ios::right). Escape Sequences: \b, \f, \n, \r, \\, \', \"

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hello, here is the completed code you wanted. Every important statement is explained using comments. Please check and let me know if you have any doubts. Thanks.

CODE

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
   int number_employees;
   double hours, rate, pay, total_pay = 0;
  
   //prompt for number of employees
   cout<<"Enter number of employees: ";
   cin>>number_employees;
  
   //loop
   for(int i = 0; i < number_employees; i++)
   {
       //prompt for hours
       cout<<"\nHours: ";
       cin>>hours;
      
       //prompt for rate
       cout<<"Rate (in dollars): ";
       cin>>rate;
      
       //calculating pay
       pay = hours * rate;
      
       //calculating total payroll
       total_pay = total_pay + pay;
      
       //printing pay per employee
       cout<<"Pay is $"<<fixed<<setprecision(2)<<pay;
   }
   //printing total payroll
   cout<<"\nAll employees processed.";
   cout<<"\nTotal payroll is "<<fixed<<setprecision(2)<<total_pay;
}

OUTPUT

CODE SCREEN SHOT

Add a comment
Know the answer?
Add Answer to:
Write, compile, and test a C++ program that uses a loop to calculate and display each...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • in C++ Write a program which uses the following arrays: empID: An array of 7 integers...

    in C++ Write a program which uses the following arrays: empID: An array of 7 integers to hold employee identification numbers. The array should be initialized with the following values: 1, 2, 3, 4, 5, 6, 7. Hours: an array of seven integers to hold the number of hours worked by each employee. payRate: an array of seven doubles to hold each employee’s hourly pay rate. Wages: an array of seven doubles to hold each employee’s gross salary. The program...

  • Program Description: Write the pseudocode for a program that will calculate and display an employee’s gross...

    Program Description: Write the pseudocode for a program that will calculate and display an employee’s gross pay. Input the number of hours an employee worked for each of the 5 days of the week. Add them all up to get his hours worked for the week. Weekly Pay is calculated by adding an employee’s normal pay plus any overtime pay. Normal hours are paid at $10/hr. Any over time is paid at $15/hr. Any hours over 40 are considered overtime....

  • Program is to be written In C++, The output should look like the screen shot. It...

    Program is to be written In C++, The output should look like the screen shot. It should allow the user to continue to ask the user to enter all employee ID's until done and then prompt the user to enter the hours and pay rate for each employee ID. Please help:( Can you please run the program to make sure the output is just like the screenshot please? It needs to have the output that is in the screenshot provided,...

  • I hope some one can help me with the Python excercise (coding) Design a program that...

    I hope some one can help me with the Python excercise (coding) Design a program that uses the following parallel arrays: ● empId: An array of seven Integers to hold employee identification numbers. The array should be initialized with the following numbers: 56588 45201 78951 87775 84512 13028 75804 ● hours: An array of seven Integers to hold the number of hours worked by each employee. ● payRate: An array of seven Reals to hold each employee’s hourly pay rate....

  • Expand the payroll program to combine two sorting techniques (Selection and Exchange sorts) for better efficiency...

    Expand the payroll program to combine two sorting techniques (Selection and Exchange sorts) for better efficiency in sorting the employee’s net pay. //I need to use an EXSEL sort in order to combine the selection and Exchange sorts for my program. I currently have a selection sort in there. Please help me with replacing this with the EXSEL sort. //My input files: //My current code with the sel sort. Please help me replace this with an EXSEL sort. #include <fstream>...

  • You are to write a program that will process employees and their pay. For each employee...

    You are to write a program that will process employees and their pay. For each employee the program will read in an employee’s name and hourly pay rate. It should also read in the number of hours worked each day for 5 days and calculate his or her total number of hours worked. You must read the hours using a loop. The program should output the employee’s name, gross pay, total withholding amount and net pay. Withholding is made up...

  • Write a C++ console application that uses functions to calculate an employee’s salary.

    Write a C++ console application that uses functions to calculate an employee’s salary.PART 1: Create a void function to print a menu asking the user to choose from the following options:1 - Annual salary2 - Monthly salary3 - Daily rate of pay4 – ExitThe void function only prints the menu. Format your cout statement to include the menu as displayed above.If the chosen option is 1- Annual Salary, ask the user for the number of hours they work perweek and...

  • C++ Linked Lists You have been hired by Employees. Inc to write an employee management system....

    C++ Linked Lists You have been hired by Employees. Inc to write an employee management system. The following are your specifications: Write a program that uses the following linked lists: bullet empId: a linked list of seven long integers to hold employee identification numbers. The array should be initialized with the following numbers: 5658845 4520125 7895122 8777541 8451277 1302850 7580489 bullet hours: a linked list of seven integers to hold the number of hours worked by each employee bullet payRate:...

  • C coding language is used. Write a program that declare parallel arrays for storing information about...

    C coding language is used. Write a program that declare parallel arrays for storing information about 10 employees. One array will store the hours each person worked for a week and a second array will store each person's weekly pay. Your program should ask the user for the number of hours each of the 10 employees worked. The pay should calculate both regular and overtime pay. Assume that all 10 employees earn $15.25 per hour. Your program should allow the...

  • Visual C# C# Visual Studio 2017 You are to create a class object called “Employee” which included eight private variable...

    Visual C# C# Visual Studio 2017 You are to create a class object called “Employee” which included eight private variables - firstN - lastN - idNum -wage: holds how much the person makes per hour -weekHrsWkd: holds how many total hours the person worked each week. - regHrsAmt: initialize to a fixed amount of 40 using constructor. - regPay - otPay After going over the regular hours, the employee gets 1.5x the wage for each additional hour worked. Methods: -...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT