Hello, Im new here to forums and learning Java. I had a test that had this type of code as an example, I had to write it from memory. My issue is it ask if the variable vacation=2 or 3 what would display. I know the answers now but got one wrong. I need it to display the output 6 and 10. I remember that at certain case there were no break. I think it was after case1 and case 4 there weren't any break that I can remember. The code is to display the sum of both variables show and boat. Basically what needs to change or taken out to display 6 or 10 when I change the assignment for vacation from 2 to 3...would appreciate the help. I think I need to erase case 5 but either way its not working so it can display 6...
public class SwitchStatement
{
public static void main(String[] args)
{
int vacation = 3;
int boat = 1, show = 10;
switch (vacation){ //if there are no break the answer is default
case 1:
show = 1;
boat = 1;
break;
case 2:
show = 2;
boat = 2;
//break;
case 3:
show = 3;
boat = 3;
break;
case 4:
show = 4;
boat = 4;
//break;
default:
case 5:
show = 5;
boat = 5;
System.out.println("The answer is" + " " + (show + boat));
break;
}
}