Tasks: Part 1: You own a store and people can buy products that are then shipped...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Tasks: Part 1: You own a store and people can buy products that are then shipped to their place. You already have some code for handling the shopping cart of products bought (see Product.java and Store.java). Now you decide to offer other things that people could buy, that is very different than the products you have been selling up to now: they can also buy an online book (actually a subscription, with a monthly payment and a duration) or a song in a sound file. The classes for these are provided to you (Online Book.java and SongFile.java). You now want to be able to add those to the shopping cart as well. Modify the classes provided (Product, Online Book, and SongFile) so that they can be put into the same ArrayList. Note: the only thing they should share is the possibility of buying them (i.e., do not use inheritance here...not even the Object class). OnlineBook and SongFile cannot do this for now, so you should add that too. Note that there is one major difference between how OnlineBook and SongFile would be bought vs. how Products are currently bought: there would not be any shipment involved. The only thing that needs to be done in the related method is to get the total price for buying those, and return such amount. Next, in the main method, create one book and one song, and add both to shopping cart. Modify the "for" loop provided, so that the "read" method is called when you get a book, and the "listen" method is called when you get a song. Part 2: Using the following array of integers: 80 40 25 65 90 77 52 29 70 For tasks a) and b) above, please show your work like in the Slides #3 and #9 in "SortingSearching.pdf" 60 a) Show (step by step) how this array would be sorted using the Selection sort algorithm. b) Show (step by step) how this array would be sorted using the Insertion sort algorithm. c) Using the sorted array, show which cells would be accessed (sequence) when searching each of the following values, using the Linear Search algorithm: 60, 25, 90, and 68. d) Using the sorted array, show which cells would be accessed (sequence) when searching each of the following values, using the Binary Search algorithm: 60, 25, 90, 68, 29, and 65. For tasks c) and d) above, just give the list of values you check in the array as you perform the algorithm. For example, if I started with the non-sorted array above and searching the value 25, using the kind of algorithm used in the "search" method in the "FlexibleCourse2.java" example, here is what I would expect as answer: search 25: 80, 40, 25 Note: tasks c) and d) above ask you to do the work on the sorted array, not the unsorted one... Tasks: Part 1: You own a store and people can buy products that are then shipped to their place. You already have some code for handling the shopping cart of products bought (see Product.java and Store.java). Now you decide to offer other things that people could buy, that is very different than the products you have been selling up to now: they can also buy an online book (actually a subscription, with a monthly payment and a duration) or a song in a sound file. The classes for these are provided to you (Online Book.java and SongFile.java). You now want to be able to add those to the shopping cart as well. Modify the classes provided (Product, Online Book, and SongFile) so that they can be put into the same ArrayList. Note: the only thing they should share is the possibility of buying them (i.e., do not use inheritance here...not even the Object class). OnlineBook and SongFile cannot do this for now, so you should add that too. Note that there is one major difference between how OnlineBook and SongFile would be bought vs. how Products are currently bought: there would not be any shipment involved. The only thing that needs to be done in the related method is to get the total price for buying those, and return such amount. Next, in the main method, create one book and one song, and add both to shopping cart. Modify the "for" loop provided, so that the "read" method is called when you get a book, and the "listen" method is called when you get a song. Part 2: Using the following array of integers: 80 40 25 65 90 77 52 29 70 For tasks a) and b) above, please show your work like in the Slides #3 and #9 in "SortingSearching.pdf" 60 a) Show (step by step) how this array would be sorted using the Selection sort algorithm. b) Show (step by step) how this array would be sorted using the Insertion sort algorithm. c) Using the sorted array, show which cells would be accessed (sequence) when searching each of the following values, using the Linear Search algorithm: 60, 25, 90, and 68. d) Using the sorted array, show which cells would be accessed (sequence) when searching each of the following values, using the Binary Search algorithm: 60, 25, 90, 68, 29, and 65. For tasks c) and d) above, just give the list of values you check in the array as you perform the algorithm. For example, if I started with the non-sorted array above and searching the value 25, using the kind of algorithm used in the "search" method in the "FlexibleCourse2.java" example, here is what I would expect as answer: search 25: 80, 40, 25 Note: tasks c) and d) above ask you to do the work on the sorted array, not the unsorted one...
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
The Crazy Eddie fraud may appear smaller and gentler than the massive billion-dollar frauds exposed in recent times, such as Bernie Madoffs Ponzi scheme, frauds in the subprime mortgage market, the...
-
Prepare the journal entries for 2, 4, 6, 8, 12 and 14 using the following information 6% bonds $1200000 par value payable in 5 years were issued for cash at 108, any premium is to be transferred to...
-
A 0.55-kg ball, attached to the end of a horizontal cord, is revolved in a circle of radius 1.3 m on a frictionless horizontal surface. If the cord will break when the tension in it exceeds 75 N,...
-
In what ways does an entrepreneur need to be a leader?
-
What performance measure would you consider most important for McDonald's? For Chevrolet?
-
Tax Agency Fund. The county collector of Lincoln County is responsible for collecting all property taxes levied by funds and governments within the boundaries of the county. To reimburse the county...
-
A small electric immersion heater is used to heat 87 g of water for a cup of instant coffee. The heater is labeled "120 watts" (it converts electrical energy to thermal energy at this rate)....
-
The Scottsville Textile Mill1 produces five different fabrics. Each fabric can be woven on one or more of the mills 38 looms. The sales departments forecast of demand for the next month is shown in...
-
How can society achieve cultural relativism?
-
What are bought and sold in a financial market? (Select all that apply.) real estate collectible coins equity securities debt securities
-
1) Write a function letter_score(letter) that takes a lowercase letter as input and returns the value of that letter as a scrabble tile. If letter is not a lowercase letter from a to z, the function...
-
If you presently have $6,200 invested that will continually earn an annual rate of 4.2%, how long will it take for your investment to triple in value?
-
Given the function ( z = x^2y + xy^2 ), calculate the partial derivatives ( \frac{\partial z}{\partial x} ) and ( \frac{\partial z}{\partial y} ). Then, find the mixed second-order partial derivative...
-
If Your Taxable Income Is Up to $ 8 , 9 2 5 $ 8 , 9 2 5 - $ 3 6 . 2 5 0 $ 3 6 , 2 5 0 - $ 8 7 . 8 5 0 2 0 1 3 Individual Tax Rates Single Individuals You Pay This Amount on the Base of the Bracket...
-
20. Compute the total ordinary deductions from the community property (common) of Reyes. 21. Compute the estate tax. 22. Compute the donor's tax due on the August 17 donation. 23. Compute the donor's...
-
Dan and Diana file a joint return. Dan earned $31,000 during the year before losing his job. Diana received Social Security benefits of $5,000. a. Determine the taxable portion of the Social Security...
-
Carmex is dedicated to providing consumers with superior lip balm formulasthat heal, soothe and protect while ensuring lips remain healthy and hydrated, exclaims Paul Woelbing, president of Carma...
-
What variables might be used to segment these consumer markets? (a). Smartphones. (b). Frozen pizzas. (c). Breakfast cereals, and (d). Soft drinks.
-
You are about to graduate from college and want a job in marketing research or sales. Go to LinkedIn. com to register and determine what information you would put on your profile to help you find a...
-
Suppose you identify 10 possible investments whose payoffs are completely independent of one another. All the investments have the same expected value and standard deviation. You have $1,000 to...
-
The rise in wealth inequality in the United States has reduced the capacity of much of the population to cope with transitory income shocks. How might you expect that to impact workers preferences...
-
Measuring risk is crucial to understanding the financial system. a. To study random future events, start by listing all the possibilities and assign a probability to each. Be sure the probabilities...
Study smarter with the SolutionInn App