Hi everyone. I'm trying to finish up this bit of code for some homework, but I can't quite figure out where I'm going wrong. I can get the code to print out fine, but when it goes to itemPrice = validValue[x], it's not changing the price, and defaulting to 15.50. Can someone tell me where I'm going wrong? I don't need the answer, but a nudge in the right direction would be nice. Thanks!
import javax.swing.*; public class Main { public static void main(String[] args) { final double NUMBER_OF_PIZZAS = 4; String[] validValues = {"S", "M", "L", "X"}; double[] prices = {6.99, 8.99, 12.50, 15.50}; String strItem; int entry; boolean validItem = false; double itemPrice = 0.0; strItem = JOptionPane.showInputDialog(null, "Enter the pizza size you want.\nS - Small\nM - Medium\nL - Large\nX - Extra Large"); for (int x = 0; x < NUMBER_OF_PIZZAS; ++x) { if (strItem.equalsIgnoreCase(validValues[x])) { validItem = true; itemPrice = prices[x]; } } if (validItem) { JOptionPane.showMessageDialog(null, "The price of a " + strItem + " pizza is $" + itemPrice); } else { JOptionPane.showMessageDialog(null, "That's not a valid pizza"); } } }