//Date: 3/16/2010
import javax.swing.*;
class PizzaChoice
{
public static void main(String[] args) throws Exception
{
char[] whatSize = { 'S', 'M', 'L', 'X'};
char size;
double[] sizePrice = {6.99, 8.99, 12.50, 15.00};
int s;
System.out.println("What size do you want?");
size = Character.toUpperCase((char)System.in.read());
for (s = 0; s < whatSize.length; ++s)
{
if (size == whatSize[s])
System.out.println("Your pizza price is $" + sizePrice[s]);
}
}
}
That top section is for the command prompt, below is what I conjured up for a dialog input box and message box, but it doesn't work to the finish!!
//Date: 3/16/2010
import javax.swing.*;
class PizzaChoice
{
public static void main(String[] args) throws Exception
{
String[] whatSize = { "S", "M", "L", "X"};
String size;
double[] sizePrice = {6.99, 8.99, 12.50, 15.00};
int s;
size = JOptionPane.showInputDialog(null, "What size do you want?");
for (s = 0; s < whatSize.length; ++s)
{
if (size == whatSize[s])
JOptionPane.showMessageDialog(null, "Your pizza price is $" + sizePrice[s]);
}
}
}