import javax.swing.JOptionPane;
import java.io.*;
public class shipwin
{
public static void main (String args [])throws IOException
{
char shipcode;
JOptionPane.showInputDialog ("Enter a shipcode: ");
shipcode = (char) System.in.read ();
switch (shipcode)
{
case 'B' : case 'b': JOptionPane.showMessage-
Dialog (null, "Battleship");break;
case 'C' : case 'c': JOptionPane.showMessage-
Dialog (null, "Cruiser");break;
case 'D' : case 'd': JOptionPane.showMessage-
Dialog (null, "Destroyer");break;
case 'G' : case 'g': JOptionPane.showMessage-
Dialog (null, "Gunboat");break;
default: JOptionPane.showMessage-
Dialog (null, "You entered an invalid code");
}
}
}
2007-09-27
20:11:07
·
4 answers
·
asked by
sheryl lyn b
2
in
Programming & Design