Question
Write method in JAVA whileSwitch() to do the following: Return type of void Declare as static Empty parameter list Declare the following variables all of
Write method in JAVA whileSwitch() to do the following:
Return type of void
Declare as static
Empty parameter list
Declare the following variables all of primitive data type int
day
rain
In a while loop that loops for seven daysIn a switch that evaluates the variable dayIf case 0
Output to the console Sunday we got 1 inch of rain
Update variable rain to equal (rain + 1)
If case 1
Output to the console Monday we got 2 inches of rain
Update variable rain to equal (rain + 2)
If case 2
Output to the console Tuesday we got 3 inches of rain
Update variable rain to equal (rain + 3)
If case 3
Output to the console Wednesday we got 4 inches of rain
Update variable rain to equal (rain + 4)
If case 4
Output to the console Thursday we got 5 inches of rain
Update variable rain to equal (rain + 5)
If case 5
Output to the console Friday we got 6 inches of rain
Update variable rain to equal (rain + 6)
If case 6
Output to the console Saturday we got 7 inch of rain
Update variable rain to equal (rain + 7)
Default case
Output to the console that the value is not valid
Increment the looping variable day by 1
Output to the console how much rain was received in the past week
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