Question: Question: Method main() should: 1. In the main method call the following methods: a. comparison(); b. forLoop(); c. whileSwitch(); Write method whileSwitch() to do the

Question:

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!