0

Switch-java

Switch statement homework: Question: Write a Java program with the help of switch statement to find sum of 12 month days according to the following cases: 1. If we want to enter 1 then program must be able to sum 12 months days 2. If we want to enter 7 then program must be able to sum all the days from 7th to 12th month. Please note: sum operation must be performed according to the range of months.

5th Jan 2022, 12:27 PM
Muzammil Khan Tareen
Muzammil Khan Tareen - avatar
3 Answers
+ 3
Please submit your attempt first so we can help you correct mistakes
5th Jan 2022, 12:30 PM
Nick
+ 3
Hello Muzammil Khan Tareen You need to ask for user input to get the month. Then you need a variable sum. int month = input; int sum = 0; switch(month){ case 1: ... case 12: default: } After each case you calculate the sum. Look into the java course how switch works.
5th Jan 2022, 2:20 PM
Denise Roßberg
Denise Roßberg - avatar
0
Sorry I just don't know How to start
5th Jan 2022, 12:32 PM
Muzammil Khan Tareen
Muzammil Khan Tareen - avatar