What size do you want?
x
Your pizza price is $15.0
Above, I chose x (which automatically puts it upperCase with the toUpperCase code, X, and then it tells me that X (X-large) is $15.00.
I wanna be able to do that using dialog boxes, but when I run it using boxes, I input what size, then the Message box comes up telling me I'm getting the pizza for $6.99, I click OK, then another box comes up, $8.99, click OK, another box pops up, $12.50, click OK, then another final windows pops up, $15.00......
I just want it to tell me the price of the one I chose, not all of them, which apparently, is because that's what I told the for loop to do,
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])
System.out.println("Your pizza price is $" + sizePrice[s]);
but I don't want to do that, I don't know the code to only show the correct price and then stop.
It seems either I'm wording it wrong in the for loop, s < whatSize.length (maybe?) or the
if (size == whatSize[s])
System.out.println("Your pizza price is $" + sizePrice[s]);
is wrong, especially the if statement.