Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
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
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 MarkThis question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
bartleby
This is a popular solution
bartleby
Trending nowThis is a popular solution!
bartleby
Step by stepSolved in 4 steps with 6 images
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
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
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
- When using two loops to traverse an array, you can use the For...Next statement to code the outer loop and use the For Each...Next statement to code the nested loop. True or False?arrow_forwardTest2_Q2 Test Content Question 1 16 Points Write a JAVA program using loop that asks the user to input seven integer numbers representing. the humidity level in Bahrain for each of the day of the week (1 represents Sunday, 2 represents Monday, etc.). The program should find and display the following: 1- the maximum humidity level and the day on which it was recorded. 2- the number of days the humidity level was lower than 40. *Assume that there is only one maximum humidity level. Sample Input / Output Enter the humidity for 1 week: 57 61 37 49 50 62 38 The Maximum Humidity is 62 for the Week Day = 6 The no. of days the humidity level < 40 is 2 Note: Your answer should follow the given sample input / output.arrow_forwardJAVA based programarrow_forward
- **using C# and Visual Studio design a program to satisfy the below problem** Create an application that generates a random number in the range of 1 through 100 and asks the user to guess what the number is. If the user’s guess is higher than the random number, the program should display "Too high, try again." If the user’s guess is lower than the random number, the program should display "Too low, try again." If the user guesses the number, the application should congratulate the user and then generate a new random number so the game can start over. Optional Enhancement: Enhance the game so it keeps count of the number of guesses that the user makes. When the user correctly guesses the random number, the program should display the number of guesses.arrow_forwardCreate a Program that asks for 10 integers (Use Arrays). Afterwards, display a navigation menu and perform the following: (1) Display the numbers (2) Display it in reverse order (3) Display the values of even indices (0th, 2nd, 4th, 6th, 8th, ..., 2n) (4) Display the values of odd indices (1st, 3rd, 5th, 7th, 9th,.., 2n+1) (5) Ask for an index k, then rotate array to the right. (6) Ask for an index k, then rotate the array to the left. Sample Input 10 45 15 26 35 25 7 12 8 3 1 10 45 15 26 35 25 7 12 8 3 2 10 45 15 26 35 25 7 12 8 3 3 10 45 15 26 35 25 7 12 8 3 4 10 45 15 26 35 25 7 12 8 3 5 2 10 45 15 26 35 25 7 12 8 3 6 2 Expected Output number: 10 45 15 26 35 25 7 12 8 3 Menu: 1. Display the numbers 2. Display it in reverse order 3. Display values of even indices 4. Display values of odd indices 5. Rotate array by k (Forward) 6. Rotate array by k (Backward) choice: 1 10 45 15 26 35 25 7 12 8 3 number: 10 45 15 26 35 25 7 12 8 3 Menu: 1. Display the numbers 2. Display it in reverse...arrow_forwardCreate a Console application that does the following:This program must use a single array to store integers and find the minimum value.1. Create an array that can hold up to 100 integers.2. Prompt the user for the number of integers to be stored in the array.3. Prompt the user for the integers to be stored in the array.4. Use a loop to iterate through the array and determine the minimum value.arrow_forward
- The program should allow the user to enter the age of the child and the number of days per week the child will be at the day care center. The program should output the appropriate weekly rate. The file provided for this lab contains all of the necessary variable declarations, except the two-dimensional array. You need to write the input statements and the code that initializes the two-dimensional array, determines the weekly rate, and prints the weekly rate. Comments in the code tell you where to write your statements. 1. Open the source code file named DayCare.cpp using Notepad or the text editor of your choice. 2. Declare and initialize the two-dimensional array. 3. Write the C++ statements that retrieve the age of the child and the number of days the child will be at the day care center. 4. Determine and print the weekly rate. 5. Save this source code file in a directory of your choice, and then make that directory your working directory. 6. Compile the source code...arrow_forwardcorrect all errors.arrow_forwardQuestion 3 - - / 0 Write a program that allows to modify an integer x between 50 and 100 to x+1 if its first decimal is 9 or 4. For example x=64 becomes 65 and x= 79 becomes 80. x is read from keyboard as a mark of a student and must be between 0 and 100. Type your answerarrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
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