Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Mr. N. Vestor owns several different stocks. Data regarding these stocks can be found in a plain text file. Write a program that will read

Mr. N. Vestor owns several different stocks. Data regarding these stocks can be found in a plain text file. Write a program that will read specific information from the file and display that information to the screen.

The spFileIOstockData.txt file contains the following information:

AMD:Advanced Micro Devices, Inc.:21.93:1.085.18%:106969413:154:5 INTC:Intel Corporation:47.04:2.725.47%:81516647:2345:25 MU:Micron Technology, Inc.:38.96:2.376.48%:58897529:98:3 WDC:Western Digital Corporation:43.16:3.027.52%:36281583:643:44 AAPL:Apple Inc.:157.76:5.063.31%:31874469:739:56 MSFT:Microsoft Corporation:107.17:0.970.91%:29183956:215:23 

The pieces of data above are delimited using the: character. Each line of data contains the following in the order listed.

  • the stock's symbol
  • name of a NASDAQ stock
  • the stock's value at the close of day the day this report was generated
  • how much the stock's value has changed since the last report
  • an arrow indicating if the stock increased or decreased in value
  • how much the stock's value has changed since the last report as a percentage
  • the share volume
  • the number of shares owned prior to this report
  • the number of shares purchased the day this report was generated
  • a single space

Use get(), getline() and ignore() as needed to read the needed pieces of data from the stock information file. Any data that is not needed should be ignored rather than read. For the first five stocks, display, to the screen, the name of the stock, the stock's value, the total number of shares owned (the number of shares owned prior to this report plus the shares purchased the day the report was generated) and display the total amount of worth (the number of shares owned multiplied by the stock's value from this report).

The above stock information would produce the following output on the screen.

student submitted image, transcription available below The output of your program should look exactly like this. Data values may differ.
Stock Name Value Quantity Total Worth Advanced Micro Devices, Inc. 21.93 159 3486.87 Intel Corporation 47.04 2370 111484.80 Micron Technology, Inc. 38.96 101 3934.96 Western Digital Corporation 43.16 687 29650.92 Apple Inc. 157.76 795 125419.20

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions