Concept explainers
Given the following code in Java and attached images( containing related code):
“sellLIFO” and “sellFIFO” methods.
2. Provide error checking so users can’t sell a stock they don’t own or
try to sell more stock than they own. Eliminate that runtime exception.
3. Must change to where user has to input the stock they want to work with, not just Google or Amazon that can be stored in the LinkedList.
4. We like the layout and design of the application so don’t change any
of the other methods or objects. Only edit the Controller.java file!
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 6 images
Awesome! the program is running perfectly! Lastly, instead of using a Hashmap, can this be done just using a LinkedList where the output should stay the same, but not using a Hashmap?
The code is missing a part.
1. Refer to the image
Running the code given does not ask for "At what selling price per share". If I want to sell the stock, it should ask me at what price I want to sell the stock, but the code provided does not do that! Please fix
Awesome! the program is running perfectly! Lastly, instead of using a Hashmap, can this be done just using a LinkedList where the output should stay the same, but not using a Hashmap?
The code is missing a part.
1. Refer to the image
Running the code given does not ask for "At what selling price per share". If I want to sell the stock, it should ask me at what price I want to sell the stock, but the code provided does not do that! Please fix
- Given the following code in Java and attached images( containing related code): //Controller (ONLY EDIT THE Controller.java file) import java.util.LinkedList; import java.util.Scanner; public class Controller { public Controller() { LinkedList<Stock> googList = new LinkedList<Stock>(); LinkedList<Stock> amazList = new LinkedList<Stock>(); Scanner input = new Scanner(System.in); do { System.out.print("Enter 1 for Google stock or 2 for Amazon, 3 to quit: "); int stockSelect = input.nextInt(); if(stockSelect == 3) break; System.out.print("Input 1 to buy, 2 to sell: "); int controlNum = input.nextInt(); System.out.print("How many stocks: "); int quantity = input.nextInt(); if(controlNum == 1) { System.out.print("At what price: "); double price =…arrow_forwardDefine the abstract base class LinkedSQD_Base using a linked implementation. Indicate whether each field and method should be public, protected, or private, and explain why. Implement each of the ADTs stack, queue, and deque as a class that extends your base class. Repeat parts a and b, but instead define and use the abstract base class ArraySQD_Base using an array-based implementation. Java programarrow_forwardCreate an implementation of each LinkedList, Queue Stack interface provided For each implementation create a tester to verify the implementation of thatdata structure performs as expected Your task is to: Implement the LinkedList interface ( fill out the implementation shell). Put your implementation through its paces by exercising each of the methods in the test harness Create a client ( a class with a main ) ‘StagBusClient’ which builds a bus route by performing the following operations on your linked list: Create (insert) 4 stations List the stations Check if a station is in the list (print result) Check for a station that exists, and one that doesn’t Remove a station List the stations Add a station before another station. List the stations Add a station after another station. Print the stations StagBusClient.java package app; import linkedList.LinkedList; import linkedList.LinkedListImpl; public class StagBusClient { public static void main(String[] args) { // create…arrow_forward
- Because a class may derive from a number of different interfaces, interfaces aid in the establishment of stronger is-a links. if anything is genuine or a fakearrow_forwardFor a weighted graph, each edge is an instance of WeightedEdge. a. WeightedEdge is an interface that must be implemented differently depending on the data type of the weights on the edges. b. WeightedEdge is a subtype of Edge. c. WeightedEdge implements the Edge interface. d. WeightedEdge is a subclass of AbstractEdge.arrow_forwardThe Java classes GenericServlet and HttpServlet may be differentiated from one another with the assistance of an example.arrow_forward
- A stack-ended queue, sometimes known as a steque, is a data type that allows push, pop, and enqueue operations. Make an API for this ADT. Create a linked-list implementation.arrow_forwardExplain the differences between GenericServlet and HttpServlet, two Java classes.arrow_forwardDraw a UML class diagram for the following code: import java.util.*; public class QueueOperationsDemo { public static void main(String[] args) { Queue<String> linkedListQueue = new LinkedList<>(); linkedListQueue.add("Apple"); linkedListQueue.add("Banana"); linkedListQueue.add("Cherry"); System.out.println("Is linkedListQueue empty? " + linkedListQueue.isEmpty()); System.out.println("Front element: " + linkedListQueue.peek()); System.out.println("Removed element: " + linkedListQueue.remove()); System.out.println("Front element after removal: " + linkedListQueue.peek()); Queue<Integer> arrayDequeQueue = new ArrayDeque<>(); arrayDequeQueue.add(10); arrayDequeQueue.add(20); arrayDequeQueue.add(30); System.out.println("Is arrayDequeQueue empty? " + arrayDequeQueue.isEmpty()); System.out.println("Front element: " + arrayDequeQueue.peek());…arrow_forward
- Simple JAVA linkedlist code implementation please help and complete any part you can - Without using the java collections interface (ie do not import java.util.List,LinkedList, Stack, Queue...)- Create an implementation of LinkedList interface- For the implementation create a tester to verify the implementation of thatdata structure performs as expected Build Bus Route – Linked List- Your task is to:o Implement the LinkedList interface (fill out the implementation shell)o Put your implementation through its paces by exercising each of themethods in the test harnesso Create a client (a class with a main) ‘BusClient’ which builds a busroute by performing the following operations on your linked list:o§ Create (insert) 4 stations§ List the stations§ Check if a station is in the list (print result)• Check for a station that exists, and onethat doesn’t§ Remove a station§ List the stations§ Add a station before another station§ List the stations§ Add a station after another station§ Print the…arrow_forwardGiven the following code in Java and attached images( containing related code): //Controller (ONLY EDIT THE Controller.java file) import java.util.LinkedList; import java.util.Scanner; public class Controller { public Controller() { LinkedList<Stock> googList = new LinkedList<Stock>(); LinkedList<Stock> amazList = new LinkedList<Stock>(); Scanner input = new Scanner(System.in); do { System.out.print("Enter 1 for Google stock or 2 for Amazon, 3 to quit: "); int stockSelect = input.nextInt(); if(stockSelect == 3) break; System.out.print("Input 1 to buy, 2 to sell: "); int controlNum = input.nextInt(); System.out.print("How many stocks: "); int quantity = input.nextInt(); if(controlNum == 1) { System.out.print("At what price: "); double price =…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education