Question: please solve this simply, begginer to exception handling. java. Smart company offer a house keeping service and ask you to write a program to calculate

Smart company offer a house keeping service and ask you to write a program to calculate the total cost for offering the service per hour as follows: The cost for one hour during weekdays is 40 S.R. The cost for one hour during weekend is 50 S.R. To accomplish this task, use the following methods as specified: main method . Ask the user to enter the number of hours and the day number. . Call the method getCost and print the cost to the user. Handle any exceptions might occur in your code and print the StackTrace in the catch block. setCost method . The method receives two parameters: the day number and the hours then return the cost as integer. Calculate the cost as specified before and return the value only if the entered day is a valid number 1 to 71 Throw an Exception with the message: "Invalid Entry" if the day number is out of the rang (1-7) Notes: . Make sure that all exceptions are handled in the main method. . Additional exceptions may occur during the test of this program. Thus, make sure that your code can avoid any other exception going uncaught All the best Sample Run 1: runs Enter the number of hours: 4 Enter the day number (1-7): 2 Cost 160 S.R. BUILD SUCCESSFUL (total time: 6 seconds) Sample Run 2: run: Enter the number of hours: 3 Enter the day number (1-7): 9 java.lang. Exception: Invalid Entry at labquiz1. LabQuiz1.getCost (LabQuiz1.java:35) at labquiz1. LabQuiz1. main(LabQuiz1.java:23) BUILD SUCCESSFUL (total time: 6 seconds) Sample Run 3 run: Enter the number of hours: 5 Enter the day number (1-7): sunday Djava.util. InputMisnatchexception at java.base/java.util.Scanner, throwfor(Scanner.java:939) at java.base/java.util.Scanner.next(Scanner.java:1594) at java.base/java.util.Scanner.nextInt (Scanner.java:2258) at java.base/java.util.Scanner.nextInt (Scanner.java:2212) at labquiz1. LabQuiz1.main(LabQuizl.java:21) BUILD SUCCESSFUL (total time: 7 seconds)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
