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...
-
What are joint costs and how are joint costs recorded?
-
Clink Inc offers a defined contribution plan to its employees. Clink will match 5 0 % of the amount withheld from employees pay up to 6 % . Data from the most recent payroll: Gross Withholding Pay...
-
What items must be included in a trial notebook?
-
Which of the following observations appear to indicate market inefficiency? Explain whether the observation appears to contradict the weak, semi-strong, or strong form of the efficient-market...
-
1 0 liters of air is contained in a balloon at a pressure of 1 6 0 kPa. The air in the balloon is heated so that it expands to 3 0 liters in a process where P / V 2 is constant. Determine the work...
-
Read the case study and answer the question below with a one page response. What does a SWOT analysis reveal about the overall attractiveness of Under Armours situation? Founded in 1996 by former...
-
During the year ended 30 June 2018, Lopma Ltd acquired an area-of-interest (Oil-X). The exploration and evaluation activities at Oil-X amounted to $52,000,000. In the year ending 30 June 2019, oil...
-
Your company has the following capital structure that you consider optimal: Ordinary shares Non-redeemable preference shares Debt 50% 15% 35% It is expected that your company's earnings and dividends...
-
Solve the ODE txx(x + 1) 1/2 = 0.
-
You are advising a client who is evaluating two potential bond investments. Bond A is a zero coupon bond with a face value of 1000 maturing in 8 years. It's current market price is 676.84. Bond B has...
-
The following function has a bug and doesn't work as expected. What is the issue with this function and how will you fix it? //lfx is greater than y, this function should return 1. //Else, this...
-
ON January 1, 2020 A and B established AB partnership. A invested 20000 cash and B invested 30000 cash. The income ratio 2:3. X achieved 10000 net incomes. A share of net income is -----
-
QUESTION 14 In a servlet, "request" is an instance of which one of the following classes? O Request HttpRequest HttpServletRequest O ServletRequest
-
A report from the college dean indicates that for the previous semester, the grade distribution for the Department of Psychology included 135 As, 158 Bs, 140 Cs, 94 Ds, and 53 Fs. Determine what kind...
-
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...
-
Derive Equation 9.85. = E{R} - E {Rk} aR i=1 k=1,2...,n, (9.85)
-
Derive the transfer functions for the following governing equations of motion: (a) \(\ddot{x}+2 \dot{x}+4 x=\cos \omega t\) (b) \(m \ddot{x}+c \dot{x}+k x=A \cos \omega t\) (c) \(m \ddot{x}+c...
-
In each of the following systems, identify the control component(s), if possible. Describe qualitatively how the control system affects system behavior: (a) airplane wing, (b) elevator, (c) standard...
Study smarter with the SolutionInn App