// 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.

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter7: File Handling And Applications
Section: Chapter Questions
Problem 14RQ
icon
Related questions
Question
// 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 <iostream>
#include <string>
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 notDone = true;               // 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)
      notDone = false;
   else
   {
      cout << "Enter hours worked: ";
      cin >> hoursWorked;
      prevDay = dayOfWeek;
   }     
    
   while(notDone == true)
   {  
      // Implement control break logic here
      // Include work done in the dayChange() function
   }
   cout << "\t\t" << DAY_FOOTER << hoursTotal << endl;
          
   return 0;

} // End of main() 
ning X
o https://ng.cengage.com/static/nb/ui/evo/index.html?elSBN=9781337274609&snapshotld%3D191860.
CENGAGE MINDTAP
Accumulating Totals in Single-Level Control Break Programs in C++
日1
Accumulating Totals in Single-Level
SuperMarket.cpp
Control Break Programs
1 // SuperMarket.cpp
2 // by employees of a
у Тools
Monday-6 hours (employee 1)
3// each day of one we
4 // Input: Interactiv
5 // Output: Report.
Tuesday-2 hours (employee 1), 3 hours (employee
2)
#include <iostream>
Tips
8 #include <string>
Wednesday-5 hours (employee 1), 3 hours
9 using namespace std;
10 int main()
Tips
(employee 2)
11 {
OU
Thursday-6 hours (employee 1)
12
W Declare variables
const string HEAD1
Friday-3 hours (employee 1), 5 hours (employee
14
const string DAY FOO
2)
15
W Leading spaces in
const string SENTINEL
double hoursWorked
16
17
Saturday-7 hours (employee 1), 7 hours
thers Hear
string dayofWeek;
double hoursTotal
18
(employee 2), 7 hours (employee 3)
19
20
string prevDay
!!
Sunday-0 hours
bool notDone
true;
21
!!
22
23
W Print two blank 1in
An example program execution is shown below:
k
24
cout << endl << endl;
25
W Print heading.
cout << "\t\t\t\t\t" <<
A Print two blank line
26
WEEKLY HOURS WORKED
28
cout << endl << endl;
29
Enter day of week or done to quit: Monday
130
A Read first record
31
cout << "Enter day of we
Enter hours worked: 2
cin >> dayofWeek;.
if(dayOfWeek
32
Monday 2
SENTINEL
Enter a day of week or done to quit: Monday
false;
34
notDone
Enter hours worked: 4
else
35
Monday 4
36
Enter a day of week or done to quit: Tuesday
上
Enter hours worked: 8
ch
Transcribed Image Text:ning X o https://ng.cengage.com/static/nb/ui/evo/index.html?elSBN=9781337274609&snapshotld%3D191860. CENGAGE MINDTAP Accumulating Totals in Single-Level Control Break Programs in C++ 日1 Accumulating Totals in Single-Level SuperMarket.cpp Control Break Programs 1 // SuperMarket.cpp 2 // by employees of a у Тools Monday-6 hours (employee 1) 3// each day of one we 4 // Input: Interactiv 5 // Output: Report. Tuesday-2 hours (employee 1), 3 hours (employee 2) #include <iostream> Tips 8 #include <string> Wednesday-5 hours (employee 1), 3 hours 9 using namespace std; 10 int main() Tips (employee 2) 11 { OU Thursday-6 hours (employee 1) 12 W Declare variables const string HEAD1 Friday-3 hours (employee 1), 5 hours (employee 14 const string DAY FOO 2) 15 W Leading spaces in const string SENTINEL double hoursWorked 16 17 Saturday-7 hours (employee 1), 7 hours thers Hear string dayofWeek; double hoursTotal 18 (employee 2), 7 hours (employee 3) 19 20 string prevDay !! Sunday-0 hours bool notDone true; 21 !! 22 23 W Print two blank 1in An example program execution is shown below: k 24 cout << endl << endl; 25 W Print heading. cout << "\t\t\t\t\t" << A Print two blank line 26 WEEKLY HOURS WORKED 28 cout << endl << endl; 29 Enter day of week or done to quit: Monday 130 A Read first record 31 cout << "Enter day of we Enter hours worked: 2 cin >> dayofWeek;. if(dayOfWeek 32 Monday 2 SENTINEL Enter a day of week or done to quit: Monday false; 34 notDone Enter hours worked: 4 else 35 Monday 4 36 Enter a day of week or done to quit: Tuesday 上 Enter hours worked: 8 ch
O A 2% https://ng.cengage.com/static/nb/ui/evo/index.html?elSBN=9781337274609&snapsho
CENGAGE MINDTAP
Accumulating Totals in Single-Level Control Break Programs in C++
Accumulating Totals in Single-Level
SuperMarket.cp
Control Break Programs
1 // SuperMar
ools
2 // by emplo
3// each day
Saturday-7 hours (employee 1), 7 hours
(employee 2), 7 hours (employee 3)
4 Input:
5// Output: F
</>
Sunday-0 hours
7 #include <io.
8 #include <str
An example program execution is shown below:
9 using namespa
10 int main()
11 {
(12
W Declare
WEEKLY HOURS WORKED
13
const strin
14
const strin
15
VA Leading
Enter day of week or done to quit: Monday
16
const string
double hours
rs Hear
Enter hours worked: 2
17
Monday 2
18
string dayof
Enter a day of week or done to quit: Monday
double hours
Enter hours worked: 4
20
string prevDa
Monday 4
21
bool notDone
Enter a day of week or done to quit: Tuesday
22
Enter hours worked:
23
A Print two
24
cout << endl
Day Total (Monday) 6
25
7/ Print headi
Tuesday 8
26
cout << "lt\t\
V/ Print two b.
Enter a day of week or done to quit: done
Cout << endl <<
Day Total (Tuesday) 8
/Read first r
cout << "Enter
Grading
cin > dayOfWeek
if(dayofWeek ==
39
54
notDone = fal
else
When you have completed your program, click the
Submit button to record your score.
36
!!
Transcribed Image Text:O A 2% https://ng.cengage.com/static/nb/ui/evo/index.html?elSBN=9781337274609&snapsho CENGAGE MINDTAP Accumulating Totals in Single-Level Control Break Programs in C++ Accumulating Totals in Single-Level SuperMarket.cp Control Break Programs 1 // SuperMar ools 2 // by emplo 3// each day Saturday-7 hours (employee 1), 7 hours (employee 2), 7 hours (employee 3) 4 Input: 5// Output: F </> Sunday-0 hours 7 #include <io. 8 #include <str An example program execution is shown below: 9 using namespa 10 int main() 11 { (12 W Declare WEEKLY HOURS WORKED 13 const strin 14 const strin 15 VA Leading Enter day of week or done to quit: Monday 16 const string double hours rs Hear Enter hours worked: 2 17 Monday 2 18 string dayof Enter a day of week or done to quit: Monday double hours Enter hours worked: 4 20 string prevDa Monday 4 21 bool notDone Enter a day of week or done to quit: Tuesday 22 Enter hours worked: 23 A Print two 24 cout << endl Day Total (Monday) 6 25 7/ Print headi Tuesday 8 26 cout << "lt\t\ V/ Print two b. Enter a day of week or done to quit: done Cout << endl << Day Total (Tuesday) 8 /Read first r cout << "Enter Grading cin > dayOfWeek if(dayofWeek == 39 54 notDone = fal else When you have completed your program, click the Submit button to record your score. 36 !!
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage