I'm making a program to calculate the speed of sound through a certain material. Here is the code:
switch (user_Choice)
{
case 1:
System.out.println("The sound wave took " + speed.getSpeedInAir() + " seconds to travel through " +
distance + " feet of Air.");
break;
case 2:
System.out.println("The sound wave took " + speed.getSpeedInWater() + " seconds to travel through " +
distance + " feet of Water.");
break;
case 3:
System.out.println("The sound wave took " + speed.getSpeedInSteel() + " seconds to travel through " +
distance + " feet of Steel.");
break;
default:
System.out.println("Not a valid input.");}
I don't know why this isn't working. Can I not have that many "+" signs per case?
EDIT: Here is the user_Choice input
System.out.println("Pick a medium (1, 2, or 3):\n1. Air\n2. Water\n3. Steel");
user_Choice = kbReader.nextInt();
System.out.print("Enter the distance the sound wave traveled in feet: ");
distance = kbReader.nextDouble();
SpeedOfSound speed = new SpeedOfSound(distance);