Question
In this lab, you will use what you have learned about accumulating totals in a single-level control break program to complete a C++ program. The
In this lab, you will use what you have learned about accumulating totals in a single-level control break program to complete a C++ program. The program should produce a report for a supermarket manager to help her keep track of the hours worked by her part-time employees. The report should include the day of the week and the total hours worked by all employees each day.
The student file provided for this lab includes the necessary variable declarations and input and output statements. You need to implement the code that recognizes when a control break should occur. You also need to complete the control break code. Be sure to accumulate the daily totals for all days in the week. Comments in the code tell you where to write your code.
I need help with fixing the structure of my code.
// SuperMarket.cpp - This program creates a report that lists weekly hours worked
// by employees of a supermarket. The report lists total hours for
// each day of one week.
// Input: Interactive
// Output: Report.
#include
#include
using namespace std;
int main()
{
// Declare variables.
const string HEAD1 = "WEEKLY HOURS WORKED";
const string DAY_FOOTER = "Day Total ";
// Leading spaces in DAY_FOOTER are intentional.
const string SENTINEL = "done"; // Named constant for sentinel value.
double hoursWorked = 0; // Current record hours.
string dayOfWeek; // Current record day of week.
double hoursTotal = 0; // Hours total for a day.
string prevDay = ""; // Previous day of week.
bool done = false; // loop control
// Print two blank lines.
cout << endl << endl;
// Print heading.
cout << "\t\t\t\t\t" << HEAD1 << endl;
// Print two blank lines.
cout << endl << endl;
// Read first record
cout << "Enter day of week or done to quit: ";
cin >> dayOfWeek;
if(dayOfWeek == SENTINEL)
done = true;
else
{
cout << "Enter hours worked: ";
cin >> hoursWorked;
prevDay = dayOfWeek;
}
while(done == false)
{
if(dayOfWeek == (prevDay)!= 0){
cout<<"\t\t"< hoursTotal = 0; prevDay = dayOfWeek; done = false; } cout< hoursTotal += hoursWorked; cout<<"Enter day of week or done to quit:"; cin>>dayOfWeek; if(dayOfWeek == 0) done = true; else{ cout<<"Enter hours worked:"; cin>>hoursWorked; done = false; } // Implement control break logic here // Include work done in the dayChange() function } cout << "\t\t" << DAY_FOOTER << hoursTotal << endl; } return 0; } // End of main()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started