I am writing program that will eventually calculate the speed of sound though a medium using the switch function, but am unable to get it to read the numbers I input, here is the code if anyone can offer some pointers.
import javax.swing.JOptionPane;
/**
*This program calculates the time it would take for sound to travel through one of three mediums.
* Cpsc118 Computer programming 1
* INSTRUCTOR John Roberts
* ASSIGNMENT Assignment #3, question #2
* @author xxx,xxx
* @version July 20 2010
*/
public class speedofsound
{
public static void main(String[] args)
{
String input;
int medium = 0;
JOptionPane.showMessageDialog (null, " Pick a medium : 1 for Air, 2 for Water and 3 for Steel");
String temp1= JOptionPane.showInputDialog(null, "Enter 1, 2 or 3");
switch (medium)
{
case 1:
System.out.println ( " You have chosen Air" );
case 2:
System.out.println ( " You have chosen Water");
case 3:
System.out.println (" You have chosen Steel");
default:
System.out.println ("Invalid choice");
}
}
}