Write a method using the following header that determines whether the day of the month is a working day and will retun "Working Day" and "Non-working Day" accordingly. The method accepts two parameters: day of week for the 1" day of the month and day of the month (you can assume each month has exactly 30 days). If the given day of the month is not a valid number, the method should return "Incorrect Day of Month". If the given initDayOfWeek is not a valid number, the method should return "Incorrect Initial Day of Week" If both numbers are incorrect, only return "Incorrect Initial Day of Week". public static String isWorkingDay (int initDayOrWeek, int dayNum) (To make the day of week easier to be represented in the program, we use int number 0 to represent Sunday, I to represent Monday, 2 to represent Tuesday .. and 6 to represent Saturday) Examples isWorkingDay (0, 1) returns "Non-working Day" . (As 1" day of the month is Sunday) isWorkingDay (1, 2) returns "Working Day" . (As 1ª day of the month is Monday, and 2nd day of the Month will be Tuesday) isWorkingDay (7, 2) returns "Incorrect Initial Day of Week" . (As 7 is not a valid day of week) isWorkingDay (7, 50) returns "Incorrect Day of Month" . (As 50 is not a valid day of month)

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter12: Exception Handling
Section: Chapter Questions
Problem 16RQ
icon
Related questions
Question
Write a method using the following header that determines whether the day of the month is a
working day and will return "Working Day" and "Non-working Day" accordingly. The
method accepts two parameters: day of week for the 1" day of the month and day of the
month (you can assume each month has exactly 30 days). If the given day of the month is
not a valid number, the method should return "Incorrect Day of Month". If the given
initDayOfWeek is not a valid number, the method should return "Incorrect Initial Day of
Week" If both numbers are incorrect, only return “Incorrect Initial Day of Week".
public static String isWorkingDay (int initDayOfWeek, int dayNum)
(To make the day of week easier to be represented in the program, we use int number 0 to
represent Sunday, 1 to represent Monday, 2 to represent Tuesday ... and 6 to represent
Saturday)
Examples:
isWorkingDay (0, 1) returns "Non-working Day". (As 1" day of the month is Sunday)
isWorkingDay (1, 2) returns "Working Day" . (As 1ª day of the month is Monday, and 2nd
day of the Month will be Tuesday)
isWorkingDay (7, 2) returns "Incorrect Initial Day of Week" . (As 7 is not a valid day of
week)
isWorkingDay (7, 50) returns *Incorrect Day of Month" . (As 50 is not a valid day of month)
Transcribed Image Text:Write a method using the following header that determines whether the day of the month is a working day and will return "Working Day" and "Non-working Day" accordingly. The method accepts two parameters: day of week for the 1" day of the month and day of the month (you can assume each month has exactly 30 days). If the given day of the month is not a valid number, the method should return "Incorrect Day of Month". If the given initDayOfWeek is not a valid number, the method should return "Incorrect Initial Day of Week" If both numbers are incorrect, only return “Incorrect Initial Day of Week". public static String isWorkingDay (int initDayOfWeek, int dayNum) (To make the day of week easier to be represented in the program, we use int number 0 to represent Sunday, 1 to represent Monday, 2 to represent Tuesday ... and 6 to represent Saturday) Examples: isWorkingDay (0, 1) returns "Non-working Day". (As 1" day of the month is Sunday) isWorkingDay (1, 2) returns "Working Day" . (As 1ª day of the month is Monday, and 2nd day of the Month will be Tuesday) isWorkingDay (7, 2) returns "Incorrect Initial Day of Week" . (As 7 is not a valid day of week) isWorkingDay (7, 50) returns *Incorrect Day of Month" . (As 50 is not a valid day of month)
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Returning value from Function
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT