Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java program that keeps stocks of a bookstore. First, you should create 3 arrays 1 string array to store book names 1 integer

image text in transcribedimage text in transcribed

Write a Java program that keeps stocks of a bookstore. First, you should create 3 arrays 1 string array to store book names 1 integer array to store amount of the books .1 double array to store price of the books All arrays should have a length of 3. You should initialize all the elements of string array to null and all elements of both integer and double arrays to 0 name null null null 000price | 00 |0 | Same index of each array refers to same book in the bookstore. There are 4 possible operation:s add, view, buy and exit. Your program should ask for a new operation until user enters 4 (exit). 1-Add (50 points) .Ask user to enter book name, amount of the book and price of the book. You may assume that the entered text will be in the following format: name, amount price (You may use Double.parseDouble(text) to convert string values to double values.) If the book exists in the bookstore, then increase the amount of the book and update the price of the book. . If the book is new, then find the first available slot and update all the arrays If all the slots are full, you should resize all 3 arrays by performing following steps o create a new temporary array of size+1 o copy all items of the original array to temporary array and add the new item to the last slot of temporary array o assign temporary array to the original array 2-View (15 points) .Print the list of available books in the bookstore. (See sample outputs.) 3-Buy (30 points) Ask user to enter book name If the entered book doesn't exist in the bookstore, you should print an error message Otherwise, you should ask the user if he/she has membership. (Yes or No) o o If the user has membership than apply 20% discount to the price of the book Otherwise, no discount will be applied (see sample outputs) After decreasing the amount of the book, if the amount becomes 0, you should update name as null and price as 0 too. (You don't need to shrink array after deletion.) 4-Exit (5 points) Print Bye!" and terminate the program Analyze sample outputs given below and write your codes accordingly

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions