You don't understand how "switch" is used in Java. When you understand how "switch" works, I think you'll realize "switch" is not the best way to solve your example.
When the code says "switch (foo) {" , each value after the "case" is a potential value for "foo". I'm assuming the weights are in pounds. Your code is testing "weight" for 1 pound, then for 2 pounds, then for 3 pounds, then for 4 pounds.
switch (foo) {
case 7:
// something to do when foo == 7
break;
case 10:
case 11:
case 12:
// something to do when foo is == 10 or == 11 or == 12
break;
default:
// something to do when foo is not equal to any of the above
break;
To fix your code, using "switch" instead of the "if" statements, part of it might read thus:
case 125: case 126: case 127: case 128: case 129:
case 130: case 131: case 132: case 133: case 134:
System.out.println ("bantamweight");
break;
You would do the same for each weight class
Your code lacks the "break" statements after each "case". The "break" statement tells the program to skip the rest of the cases, and jump to whatever comes after the switch code block. What's worse, without a "break", it falls through into the next "case" blocks, and executes the code there, without retesting the "switch" value. It keeps falling through until it reaches the end of the "switch" block or a "break" statement.
The easiest way to fix your code is to delete the "switch (weight)" and all the "case" statements. You might want to change the "if" statements to "else if", except for the first. Remove the "default:" statement, and precede the print with "else".
Here is a hypothetical example of using "switch" for a college student who sets the alarm one hour before the start time of his first class of the day. The days of weeks are constants.
switch (dayOfWeek) {
case MONDAY:
case WEDNESDAY:
case FRIDAY:
myAlarm.setTime ("09:00"); // setting a time turns on alarm if it is off
break;
case TUESDAY:
case THURSDAY:
myAlarm.setTime ("06:45");
break;
case SUNDAY:
case SATURDAY:
myAlarm.setOn (false);
break;
// no default;
}