Question: // TO DO: add your implementation and JavaDocs. //These are all the imports you are allowed, don't add any more! import java.util.Scanner; import java.io.File; import

// TO DO: add your implementation and JavaDocs. //These are all the imports you are allowed, don't add any more! import java.util.Scanner; import java.io.File; import java.io.IOException; import java.util.Iterator;

public class StockMonitor {

// NO ADDITIONAL CLASS/INSTANCE MEMBERS SHOULD BE ADDED // YOU CAN ADDITIONAL PRIVATE HELPER METHODS

public ThreeTenDLList fileToPriceList(String filename) throws IOException { //Given a file name, open that file in a scanner and create a list of prices: // - the values in the list should be the integers read in each time you call // nextInt() on the scanner; // - from head to tail, the values should follow the order from the input file // return an empty list if file is empty

//default return, remove or updated as needed return null; }

public int stepProcess(int day, int price) { //perform one step of span measurement: // - determine and return the span of the given day and price using recordStack // - additional updates to perform: // - add the measured span to the back of spanList // - add the pair of to the top of recordStack // - update priceSpanMap as needed to ensure it always records the max span // of each price we have processed // // Assume day and price are always non-negative // // With your implementation of this method, the updating loop in runPrograms() // should be O(n) in non-debug mode (i.e. excluding printing overhead) // where n is the number of prices processed // - assume hashMap updating and searching is O(1)

//default return, remove or updated as needed return -1;

}

public int reportMaxSpan(int price){ // Use priceMap to find out and return the current max span for the given price // if price is not present in priceMap, return 0 // O(1) if hashMap searching is O(1) //default return, remove or updated as needed return -1; } public String spanRecordToString(){ // return a string to report the max span of each price in priceList // - only report each price once // - follow the same order as the first occurence of each price // - each price report should use the same format of "price:maxSpan" // - a single space should be padded between price reports // - no leading or trailing whitespaces in the return string // - return an empty string if priceList is empty // O(n) where n is the length of price list // - assume hashMap updating and searching is O(1) // //default return, remove or updated as needed return null; }

public static void testMain() { //edit this as much as you want, if you use main without any arguments, //this is the method that will be run instead of the program System.out.println("You need to put test code in testMain() to run StockMonitor with no parameters."); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!