Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

code I'd wrong and I can't figure out how to fix it. please help 5.6 Lab 31: Sum and Average Write a program that computes

code I'd wrong and I can't figure out how to fix it. please help

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

5.6 Lab 31: Sum and Average Write a program that computes the total hours worked and the average hours worked for a user-defined number of employees. Your program should first read in the number of employees and then the number of hours worked for each of those employees. Output the number of hours worked for each employee after the value is read in The program should accomplish the following objectives: include self-documenting variable names of type integer comments, and properly spaced statements make use of a FOR loop to read in the hours worked for each employee and output that value, sum the hours using an accumulator variable, display the sum outside the loop, calculate and display the average hours worked outside the loop (display the average with 2 significant digits after the decimal point . Hint Inside the for loop you will need to read in the hours worked output the value in the specified format, and add the hours value to an accumulator variable. Don't forget to initialize your accumulator variable to o before entering the for loop. For more information and examples, refer to slide 4 of CS1336_Lect5d_more_on_FOR_loop pptx and Pr5-12.cpp. When the input is as shown in Figure 1. your program should produce output as shown in Figure 2. Figure 1. (sample input) 3 25 12 15 Figure 2: (sample output) Employee 1 worked 25 hours Employee 2 worked 12 hours Employee 3 worked 15 hours The sum of hours worked by 3 employees is 52 The average number of hours worked is 17.33 Load derauit template 1/1 Ryan Dewey 2 C51336. DMI 3 Lab 31 4 #include 5 #include 6 using namespace std; 7 int main() 8 { int numOfEmployee; 10 cin > numOfEmployee; int n = numOfEmployee; int hoursin): for(inte; i> hours [i]: forinti<>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions