Question
Imagine you work 8 hours from Monday to Thursday, 6 hours on Friday, 4 hours on Saturday, and you are off on Sunday. Write a
Imagine you work 8 hours from Monday to Thursday, 6 hours on Friday, 4 hours on Saturday, and you are off on Sunday. Write a Java program to accept the day index as an integer from the user and display the hours. In a while loop continuously ask the user and display the hours worked. Terminate the program when the user enters an index outside 0-6. Use a switch statement; do not use an if-else structure. Here is an example of how a user interacts with your program:
Program: Please enter a day index. Use 0 for Sunday, 1 for Monday , 2 for Tuesday, and so on. User : 2 Program: You work 8 hours on Tuesdays.
Program: Please enter a day index. Use 0 for Sunday, 1 for Monday , 2 for Tuesday, and so on. User : -1 Program: Program terminating.
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