Input interactive 4 2018 assignment 7 place your name

This preview shows page 9 - 11 out of 11 pages.

// Input: Interactive
4, 2018 [ ASSIGNMENT #7 ] Place your name here // 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 ) { if (dayOfWeek != prevDay) { cout << "\t\t" << DAY_FOOTER << hoursTotal << endl << endl; hoursTotal = 0; prevDay = dayOfWeek; } hoursTotal += hoursWorked; cout << "\t\t\t\t\t\t" << prevDay << " " << hoursWorked << endl; cout << "Enter a day of week or done to quit: " ; cin >> dayOfWeek; if (dayOfWeek == SENTINEL) { notDone = false ; } else { cout << "Enter hours worked: " ;
4, 2018 [ ASSIGNMENT #7 ] Place your name here cin >> hoursWorked; } } cout << "\t\t" << DAY_FOOTER << hoursTotal << endl; return 0; } // End of main() Part III – MindTap Unit 7 Review Complete all activites assigned to this unit in MindTap tool.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture