Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

There are 2 arrays, the first contains
item numbers in inventory and the second parallel array contains the price of the items. The
user will enter the item number they want to purchase, the program checks to see if it is a valid
entry. If it is valid, it will tell the user the price of the item. If it is an invalid item, a message will
display telling the user they entered an invalid item. Type up the code below, execute the
program a few times.

Transcribed Image Text:Import javax.swing.*: public class ParallelArrays { public static void main(String[] args) { II Variables needed Int item; double price = 0.0; String itemEntered = boolean valid = false; // Set up arrays Int[] items Arr = {101, 102, 103, 452, 524, 601, 775); double priceArr(7.52, 18.36, 1.25, 450.99, 19.99, 24.97, 101.33); // Use a loop to allow the user to order items do { II Ask the user to enter an item to purchase itemEntered = JOptionPane.show/nputDialog(null, "Enter the item number to order, enter '9999' to quit"); item= Integer.parse/nfitemEntered);
Transcribed Image Text:item + " is $" + price); } } // If the item number entered is valid if (!itemEntered.equals("9999")) } { + item + " is invalid, please try again."); // Loop through the items array to see if it there for (int x = 0; x< itemsArr.length; x++) { } else // If the item number is found if (item == itemsArr[x]) { } if (valid == true) } valid = true; price = priceArr[x]; JOptionPane.showMessageDialog(null, "The price of item " + JOptionPane.showMessageDialog(null, "The item you chose: " // Reset the values price = 0.0; itemEntered = ""; valid = false; while (!itemEntered.equals("9999")); JOptionPane.showMessageDialog(null, "Program complete");
Expert Solution
Check Mark
Still need help?
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

I did not ask for a the output on a GUI. I need lines

Solution
Bartleby Expert
by Bartleby Expert
SEE SOLUTION
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

I did not ask for a the output on a GUI. I need lines

Solution
Bartleby Expert
by Bartleby Expert
SEE SOLUTION
Knowledge Booster
Background pattern image
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
    Recommended textbooks for you
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education