Question

THIS CODE SHOULD BE MODIFIED TO READ SuperMarket.dat instead of Inputting and Outputting. SuperMarket.dat Monday 4...

THIS CODE SHOULD BE MODIFIED TO READ SuperMarket.dat instead of Inputting and Outputting.
SuperMarket.dat
Monday
4
Monday
6
Monday
2
Tuesday
3
Tuesday
2
Wednesday
3
Wednesday
5
Wednesday
7
Thursday
5
Friday
4
Friday
3
Friday
4
Saturday
8
Saturday
8
Saturday
8
Sunday
0
QUESTION:
Write the control break code, including the code for the dayChange() method, in the main() method.
// 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 javax.swing.*;


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

                // 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 
                dayOfWeek = JOptionPane.showInputDialog("Enter day of week or done to quit: ");
                if(dayOfWeek.compareTo(SENTINEL) == 0)
                        done = true;
                else
                {
                        hoursWorkedString = JOptionPane.showInputDialog("Enter hours worked: ");
                        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 + hoursTotal);
                                        
                System.exit(0);

        } // End of main() method.
        
} // End of SuperMarket class.
0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
THIS CODE SHOULD BE MODIFIED TO READ SuperMarket.dat instead of Inputting and Outputting. SuperMarket.dat Monday 4...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • PYTHON CODE First Code: Write a program that uses a text file to store the daysand...

    PYTHON CODE First Code: Write a program that uses a text file to store the daysand hours that a user worked in a week. The program should begin by prompting for the number of days worked in the week. It should continue with a loop for input of the days and hours and for writing these to the file, each on its own line. Sample Output (inputs shown in boldface) How many days did you work this week? 5 Enter...

  • Using the function you wrote in part 3a (refer to the bottom), write another function that, given the number of days in the month, and the day that the month starts on, the number of days that Inky Bl...

    Using the function you wrote in part 3a (refer to the bottom), write another function that, given the number of days in the month, and the day that the month starts on, the number of days that Inky Blinky Pinky and Clyde will get to play pinball in that month. The function provided will increment the day of the week to the next correct day. Function written in 3a): def pinball(dayOfWeek, dayOfMonth) : if dayOfMonth % 4 ==0: return "Pinky"...

  • Please Refactor this Assignment by using Arraylist instead of Array. import java.util.Scanner; public class DaysOfWeeks {...

    Please Refactor this Assignment by using Arraylist instead of Array. import java.util.Scanner; public class DaysOfWeeks { public static void main(String[] args) { String DAY_OF_WEEKS[] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}; char ch; int n; Scanner scanner = new Scanner(System.in); do { System.out.print("Enter the day of the Week: "); n = scanner.nextInt() - 1; if (n >= 0 && n <= 6) System.out.println("The day of the week is " + DAY_OF_WEEKS[n] + "."); else System.out.println("Invalid Entry"); System.out.print("Try again (Y/N): "); ch = scanner.next().charAt(0); }while(ch=='Y'); }...

  • Zeller's congruence is an algorithm developed to calculate the day of the week. Write a program...

    Zeller's congruence is an algorithm developed to calculate the day of the week. Write a program that prompts the user to enter a year, month, day of month and it displays the name of the week. Here is my source code. I need it broke down into a flowchart. public static void main(String[] args) {        //all variables are initialized to 0, because local variables require at least an initial value before use        Scanner input = new...

  • Must be written in java. Modularize the following code. //CIS 183 Lab 4 //Joseph Yousef import...

    Must be written in java. Modularize the following code. //CIS 183 Lab 4 //Joseph Yousef import java.util.*; public class SalaryCalc { public static void main(String [] args) { Scanner input = new Scanner(System.in); int sentinelValue = 1; //initializes sentinelValue value to 1 to be used in while loop while (sentinelValue == 1) { System.out.println("Enter 1 to enter employee, or enter 2 to end process: ");    sentinelValue = input.nextInt(); input.nextLine(); System.out.println("enter employee name: "); String employeeName = input.nextLine(); System.out.println("enter day...

  • Need Help Filling in Areas: /** Based on a Big Java problem You have to write...

    Need Help Filling in Areas: /** Based on a Big Java problem You have to write a static method that removes every other element from a linked list. Expected output: [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday] [Monday, Wednesday, Friday] [Wednesday] [] */ public class DownSizeTester { public static void main(String[] args) { LinkedList list = new LinkedList() ; list.add("Sunday") ; list.add("Monday") ; list.add("Tuesday") ; list.add("Wednesday") ; list.add("Thursday") ; list.add("Friday") ; list.add("Saturday") ; System.out.println(list) ; downsize(list) ; System.out.println(list) ; downsize(list)...

  • need help with java questions The following snippet of code would produce what outcome? public static...

    need help with java questions The following snippet of code would produce what outcome? public static void main(String 2 [] args) { int day = 5; switch (day) { case 1: System.out.println("Monday "); case 2: System.out.println("Tuesday "); case 3: System.out.println("Wednesday "); case 4: System.out.println("Thursday "); case 5: System.out.println("Friday "); case 6: System.out.println("Saturday "); case 7: System.out.println("Sunday "); break; default: System.out.println("Invalid Day "); } } Invalid Day Friday Saturday Sunday Invalid Day Friday Friday Saturday Sunday What will be the output...

  • Your professor is hoping to get a summer job flipping burgers at the local burger joint....

    Your professor is hoping to get a summer job flipping burgers at the local burger joint. His starting salary will be $7.25 per hour. However, there are certain incentives to encourage him to work extra hours. It is calculated as follows per day: •$7.25 for the first 6 hours he works per day, Monday through Friday .•$8.25 for the next 2 hours he works per day, Monday through Friday. •$11.25 for each hour he works over 8 hours in a...

  • General Requirements: • You should create your programs with good programming style and form using proper blank spaces, indentation and braces to make your code easy to read and understand; • You sho...

    General Requirements: • You should create your programs with good programming style and form using proper blank spaces, indentation and braces to make your code easy to read and understand; • You should create identifiers with sensible names; • You should make comments to describe your code segments where they are necessary for readers to understand what your code intends to achieve. • Logical structures and statements are properly used for specific purposes. Objectives This assignment requires you to write...

  • Need this program ASAP C++ language 1b. Write the implementation file timeClock.cpp for the class TimeClock....

    Need this program ASAP C++ language 1b. Write the implementation file timeClock.cpp for the class TimeClock. Com pile the file, and save it in the Chap 13 folder of your Student Data Files. 1c. Write a C++ program named weeklyPay.cpp to test your class Timeclock Your program should ask the user how many hours the user worked each day of the week. An object should be created for each day of the week with the number of hours for each...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT