JAVA PROGRAM In this lab, you will use what you have learned about accumulating totals in a single-level control break program to complete a Java 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. Expected output is attached below. Instructions Study the prewritten code to understand what has already been done. Write the control break code, including the code for the dayChange() method, in the main() method. Execute this program using the following input values: Monday – 6 hours (employee 1), 3 hours (employee 2), 4 hours (employee 3) Tuesday – 4 hours (employee 1), 2 hours (employee 2) Wednesday – 2 hours (employee 1), 4 hours (employee 2), 6 hours (employee 3) Thursday – 4 hours (employee 1) Friday – 3 hours (employee 1), 4 hours (employee 2), 3 hours (employee 3) Saturday – 7 hours (employee 1), 7 hours (employee 2), 7 hours (employee 3) Sunday – 0 hours   Initial code: // SuperMarket.java - 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.  import java.util.Scanner; public class SuperMarket {    public static void main(String args[])     {       // Declare variables.       final String HEAD1 = "WEEKLY HOURS WORKED";       final String DAY_FOOTER = "          Day Total ";  // Leading spaces are intentional.       final String SENTINEL = "done";     // Named constant for sentinel value.        double hoursWorked = 0;             // Current record hours.       String hoursWorkedString = "";      // String version of hours       String dayOfWeek;       // Current record day of week.       double hoursTotal = 0;           // Hours total for a day.       String prevDay = "";             // Previous day of week.       boolean done = false;            // loop control       Scanner input = new Scanner(System.in);       // Print two blank lines.       System.out.println();        System.out.println();        // Print heading.       System.out.println(HEAD1);       // Print two blank lines.       System.out.println();        System.out.println();       // Read first record        System.out.println("Enter day of week or done to quit: ");       dayOfWeek = input.nextLine();       if(dayOfWeek.compareTo(SENTINEL) == 0)          done = true;       else       {          System.out.print("Enter hours worked: ");          hoursWorkedString = input.nextLine();          hoursWorked = Integer.parseInt(hoursWorkedString);           prevDay = dayOfWeek;       }                        while(done == false)       {            // Implement control break logic here               // Include work done in the dayChange() method       }           System.out.println(DAY_FOOTER + "(" + prevDay + ") " + hoursTotal);                       System.exit(0);    } // End of main() method.     } // End of SuperMarket class.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

JAVA PROGRAM

In this lab, you will use what you have learned about accumulating totals in a single-level control break program to complete a Java 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. Expected output is attached below.

Instructions

  1. Study the prewritten code to understand what has already been done.
  2. Write the control break code, including the code for the dayChange() method, in the main() method.
  3. Execute this program using the following input values:

Monday – 6 hours (employee 1), 3 hours (employee 2), 4 hours (employee 3)

Tuesday – 4 hours (employee 1), 2 hours (employee 2)

Wednesday – 2 hours (employee 1), 4 hours (employee 2), 6 hours (employee 3)

Thursday – 4 hours (employee 1)

Friday – 3 hours (employee 1), 4 hours (employee 2), 3 hours (employee 3)

Saturday – 7 hours (employee 1), 7 hours (employee 2), 7 hours (employee 3)

Sunday – 0 hours

 

Initial code:

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

import java.util.Scanner;


public class SuperMarket
{
   public static void main(String args[]) 
   {
      // Declare variables.
      final String HEAD1 = "WEEKLY HOURS WORKED";
      final String DAY_FOOTER = "          Day Total ";  // Leading spaces are intentional.
      final String SENTINEL = "done";     // Named constant for sentinel value. 
      double hoursWorked = 0;             // Current record hours.
      String hoursWorkedString = "";      // String version of hours
      String dayOfWeek;       // Current record day of week.
      double hoursTotal = 0;           // Hours total for a day.
      String prevDay = "";             // Previous day of week.
      boolean done = false;            // loop control
      Scanner input = new Scanner(System.in);
      // Print two blank lines.
      System.out.println(); 
      System.out.println(); 
      // Print heading.
      System.out.println(HEAD1);
      // Print two blank lines.
      System.out.println(); 
      System.out.println();

      // Read first record 
      System.out.println("Enter day of week or done to quit: ");
      dayOfWeek = input.nextLine();
      if(dayOfWeek.compareTo(SENTINEL) == 0)
         done = true;
      else
      {
         System.out.print("Enter hours worked: ");
         hoursWorkedString = input.nextLine();
         hoursWorked = Integer.parseInt(hoursWorkedString); 
         prevDay = dayOfWeek;
      }
      
         
      while(done == false)
      {  
         // Implement control break logic here
              // Include work done in the dayChange() method
      }
   
      System.out.println(DAY_FOOTER + "(" + prevDay + ") " + hoursTotal);
               
      System.exit(0);

   } // End of main() method.
   
} // End of SuperMarket class.

 

WEEKLY HOURSs WORKED
Enter day of week or done to quit:
Monday
Enter hours worked:
2
Monday 2.0
Enter a day of week or done to quit:
Monday
Enter hours worked:
4
Monday 4.0
Enter a day of week or done to quit:
Tuesday
Enter hours worked:
8
Day Total (Monday) 6.0
Tuesday 8.0
Enter a day of week or done to quit:
done
Day Total (Tuesday) 8.0
Transcribed Image Text:WEEKLY HOURSs WORKED Enter day of week or done to quit: Monday Enter hours worked: 2 Monday 2.0 Enter a day of week or done to quit: Monday Enter hours worked: 4 Monday 4.0 Enter a day of week or done to quit: Tuesday Enter hours worked: 8 Day Total (Monday) 6.0 Tuesday 8.0 Enter a day of week or done to quit: done Day Total (Tuesday) 8.0
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Knowledge Booster
Graphical User Interface
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education