**New course!**Every coder should learn

**Generative AI!**

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.

3 Answers

+ 3

Please submit your attempt first so we can help you correct mistakes

+ 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.

0

Sorry I just don't know
How to start