C++ Programming Computer Science Worksheet

User Generated

Enlmmmk

Computer Science

Description

Unformatted Attachment Preview

The STL (Standard Template Library) in C++ provides many common data structures used in day-to-day programming. In this lab we'll explore the use of a map, which holds a (key, value) pair and provides fast lookups of a value for a given key. Assignment Write a C++ program that provides a simple stock symbol lookup service based on an input data file. It should prompt the user for a menu to either (1) load a data file, or (2) get the stock price of a single stock. Use an STL map to hold a (key, value) pair of a stock symbol (i.e. GOOG for Google) and its closing price. The CSV file provided in this module - prices.csv -- should serve as the input file to the program. This CSV file has only two columns: a stock symbol and its closing price. To process the file, you may want to use the fields[] array processing code from previous labs. Requirements 1. Your program must use a map template to store a stock price symbol (a string) and a stock price (a double). An overview and some examples are provided in pp. 1054-1061 of the textbook (in Chapter 17). 2. Output the stock price with two digits past the decimal point precision. 3. Each time a file is loaded, overwrite all the data from the previous load. 4. The user should be able to fetch any stock symbol's price from the file. 5. Loop for input until the user requests an exit (types a 'Q'). What to Submit in Canvas Submit your .cpp file and a screenshot of one run of the program, as usual. Example Output MENU L Load a data file G Get the last closing price of a stock Q quit ...your choice: L Filename to load? prices.csv File loaded, read 2270 entries. MENU L Load a data file G Get the price of a stock Q quit ...your choice: G Which stock symbol? AAPL Yesterday's closing price of AAPL was $317.13. MENU L Load a data file G Get the price of a stock Q quit ...your choice: Q Exiting... PreviousNext
Purchase answer to see full attachment
Explanation & Answer:
1 Script
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

It is ready:) please tell me if you wa...


Anonymous
Really helpful material, saved me a great deal of time.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Similar Content

Related Tags