Question
In JAVA whileSwitch method: Method main() should: 1. In the main method call the following methods: a. comparison(); b. forLoop(); c. whileSwitch(); Write method whileSwitch()
In JAVA whileSwitch method:
Method main() should:
1. In the main method call the following methods:
a. comparison();
b. forLoop();
c. whileSwitch();
Write method whileSwitch() to do the following:
1. Return type of void
2. Declare as static
3. Empty parameter list
4. Declare the following variables all of primitive data type int
a. day
b. rain
5. In a while loop that loops for seven days
a. In a switch that evaluates the variable day
i. If case 0
1. Output to the console Sunday we got 1 inch of rain
2. Update variable rain to equal (rain + 1)
ii. If case 1
1. Output to the console Monday we got 2 inches of rain
2. Update variable rain to equal (rain + 2)
iii. If case 2
1. Output to the console Tuesday we got 3 inches of rain
2. Update variable rain to equal (rain + 3)
iv. If case 3
1. Output to the console Wednesday we got 4 inches of rain
2. Update variable rain to equal (rain + 4)
v. If case 4
1. Output to the console Thursday we got 5 inches of rain
2. Update variable rain to equal (rain + 5)
vi. If case 5
1. Output to the console Friday we got 6 inches of rain
2. Update variable rain to equal (rain + 6)
vii. If case 6
1. Output to the console Saturday we got 7 inch of rain
2. Update variable rain to equal (rain + 7)
viii. Default case
1. Output to the console that the value is not valid
b. 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