Question
CS2336 Fall 2018 Programming Assignment 2 Due Friday, October 5 th, 2018 at 11:59 PM Develop a program for an online store which sells dvds
CS2336 Fall 2018 Programming Assignment 2 Due Friday, October 5 th, 2018 at 11:59 PM
Develop a program for an online store which sells dvds and books (items). The store will have a cart which will contain the items the user wants to purchase and their prices. The inventory for books and dvds will be stored in two separate String arrays which will contain the names of the books and the names of the dvds. In addition, two separate arrays of type double will be used to store the price corresponding to each item. You will create the arrays and populate them with the following data at the beginning of your program (you dont need to input this data from the User, you can simple initialize the arrays as such). This is how the arrays will look: books Intro to Java Intro to C++ Python Perl C# booksPrices 45.99 89.34 100.00 25.00 49.99 dvds Snow White Cinderella Dumbo Bambi Frozen dvdsPrices 19.99 24.99 17.99 21.99 24.99 Moreover, you will implement the cart as two arrays too. The first array is for the names of the items the user wishes to purchase (books or dvds). The second is for the corresponding prices. You can assume a maximum cart size of 5 items, i.e., the User cannot have more than 5 items in their cart. After you create and initialize all the arrays, the program will then display a menu for the user by calling the method displayMenu(). The method will display the following lines when called: **Welcome to the Comets Books and DVDs Store** Choose from the following options: 1 - Browse books inventory (price low to high) 2 - Browse DVDs inventory (price low to high) 3 - Add a book to the cart 4 - Add a DVD to the cart 5 - View cart 6 - Checkout 7 - Cancel Order 8 - Exit store Then, within a loop, if the user enters an option that is not 1, 2, 3, 4, 5, 6, 7 or 8, display the message This option is not acceptable and loop back to redisplay the menu. Continue in this manner until a correct option is input. If option 1 is entered, call the method displayArrays()with the following signature: displayArrays(String[] itemsArray, double[] pricesArray, String itemType); to display the inventory. Also keep in mind that we want to display the inventory in the order of low to high in terms of price. You can implement any sorting algorithm (EXCEPT bubble sort) that we talked about in class to sort the arrays. You should then pass the correct two arrays and a String (Books or DVDs) to the method as shown above depending on which option gets selected. The method should display the arrays in the following format (the books and their prices are used here as the example; the same formatting applies to DVDs): Inventory Number Books Prices ------------------------------------------------- 4 Perl $25.00 1 Intro to Java $45.99 5 C# $49.99 2 Intro to C++ $89.34 3 Python $100.00 If option 3 is selected, call the method getInventoryNumber()- the method should ask the user to enter the inventory number they wish to purchase (from the list in Option 1) and -1 if they wish to redisplay the menu and not select an inventory. Then the method will read the inventory number and return the number entered by the user. You can take the inventory number which gets returned and remove 1 from it to get the correct index into the array. Use the index to retrieve the correct item and corresponding price, and then add them to the cart array. The above discussion applies for option 4 (and correspondingly option 2) as well. If option 5 is selected, you can overload the displayArrays()method (or create a separate method) to accept just the arrays and display the cart contents similar to the way you have displayed the inventory. Here is what the output should look like format-wise (you can call the getTotal() method to get the current total, see option 6 below): Items Prices ------------------------ Intro to Java $45.99 Bambi $21.99 ------------------------ Total + tax $73.58 If the arrays are empty display your cart is empty followed by the menu. If option 6 is selected, call the method getTotal() which accepts as input, the price array and returns the total by looping over prices and calculating the total. Make sure you also add an 8.25% tax to the total. Display the total for the user and clear the arrays (see option 5). Use an enhanced for loop to iterate over prices in this method and find the total. If option 7 is selected, call the clearArrays() method and pass it the cartItems and prices arrays. In the method, you will clear the arrays to remove all the items which have been added to cancel the order. Continue this looping until option 8 is selected. When option 8 is entered, end the program. Submit only your source code .java file(s) through eLearning.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started