FindPrice - itemOrdered = Integer.parseInt(strItem); i...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import javax.swing.*; public class FindPrice { public static void main(String[ ] args) { boolean validItem = false; int [] validValues = { 101, 108, 201, 213, 266, 304, 311, 409, 411, 412}; double [] prices = { .29, 1.23, 3.5, .69, 5.79, 3.19, 10.00, 98.00, 100.00, 35.00}; d String strItem; int itemOrdered; double itemPrice = 0.0; strItem = JOptionPane.showInputDialog("Enter the Item number");
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: itemOrdered = Integer.parseInt(strItem); i for(int x = 0; x < validValues.length; ++x) { if (itemOrdered == validValues[x]) { validItem = true; itemPrice = prices[x]; }} if (validItem) JOptionPane.showMessageDialog( null,"The price for the Item" + itemOrdered+ " is $" + itemPrice); else JOptionPane.showMessageDialog( null, "Invalid Entry!!"); System.exit(0); }}...
View Full Document

This note was uploaded on 10/04/2010 for the course COMPUTER S 106 taught by Professor Moore during the Spring '08 term at Clark Atlanta.

Ask a homework question - tutors are online