/*Additional selection structures 16/3/2015 Programme to display weight on a given planet*/
import java.util.*;
public class planets
{
public static void main (String []args)
{
Scanner keyboardIn = new Scanner (System.in);
int weight;
char planet;
double planet_weight;
System.out.print ("Enter your weight");
weight = keyboardIn.nextInt ();
System.out.print ("Enter your planet of choice");
planet = keyboardIn.next().charAt(0);
switch (weight)
{
case 'M': case 'm':
planet_weight = weight * 0.4;
System.out.print ("Your weight on Mercury is"+ planet_weight);
break;
case 'V': case 'v':
planet_weight = weight * 0.9;
System.out.print ("Your weight on Venus is"+ planet_weight);
break;
case 'J': case 'j':
planet_weight = weight * 2.5;
System.out.print ("Your weight on Jupiter is"+ planet_weight);
case 'S': case 's':
planet_weight = weight * 1.1;
System.out.print ("Your weight on Saturn is"+ planet_weight);
default:
System.out.print ("Invalid entry");
}
}
}
This is the piece of code I'm working with. It has to be done in a switch structure. The problem I am having is that after asking for the input for weight and and planet it skips all the options and goes straight to incalid entry. I feel like I am missing something really obvious but this is the first time we have had to do a switch structure with a calculations.
Thanks