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.
AMZN~Amazon.Com Inc~1,402.05~+24.10~+1.75%~4,854,900~6,806,813~01/26/18~1523 AAPL~Apple Inc~171.51~+0.40~+0.23%~39,128,000~6,710,843~01/26/18~1224 BABA~Alibaba Group Holding Ltd~205.22~+6.89~+3.47%~23,757,801~4,875,576~01/26/18~100 INTC~Intel Corp~50.08~+4.78~+10.55%~86,903,102~4,352,107~01/26/18~2213 VMW~Vmware Inc~150.00~+12.37~+8.99%~27,806,600~4,170,990~01/26/18~1745 WYNN~Wynn Resorts Ltd~180.29~-20.31~-10.12%~22,140,102~3,991,639~01/26/18~500 FB~Facebook Inc~190.00~+2.52~+1.34%~17,745,000~3,371,550~01/26/18~750 NVDA~Nvidia Corp~243.33~+6.98~+2.95%~12,902,001~3,139,444~01/26/18~1195 NFLX~Netflix Inc~274.60~+4.90~+1.82%~11,016,300~3,025,076~01/26/18~812 SBUX~Starbucks Corp~57.99~-2.56~-4.23%~51,846,000~3,006,550~01/26/18~915 DVMT~Dell Technologies Inc Cl V~82.74~-5.70~-6.45%~35,703,301~2,954,091~01/26/18~1611 MSFT~Microsoft Corp~94.06~+1.73~+1.87%~29,168,799~2,743,617~01/26/18~1751 GOOGL~Alphabet Class A~1,187.56~+5.42~+0.46%~2,107,300~2,502,545~01/26/18~2462 ABBV~Abbvie Inc~123.21~+14.91~+13.77%~19,614,201~2,416,666~01/26/18~10 GOOG~Alphabet Class C~1,175.84~+5.47~+0.47%~2,018,300~2,373,198~01/26/18~1675 PFE~Pfizer Inc~39.01~+1.78~+4.78%~48,805,004~1,903,883~01/26/18~55
The pieces of data above are delimited using the ~ character. Each line of data contains the following in the order listed.
a single space
the stock's symbol
name of a NASDAQ stock
the stock's value at close of day indicated by report date
how much the stock's value has changed since the last report
how much the stock's value has changed since the last report as a percentage
the number of contracts traded for the day
the price volume (current price times current volume divided by 1000)
the report date
the number of shares owned
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 the name of the stock, the stock's value and the number of shares owned. You should then calculate and display the total amount of worth (the number of shares multiplied by the stock's value).
Challenge: Display the numbers using commas.
#include <iostream>
#include <cstdlib>
#include <sstream>
#include <string>
#include <fstream>
#include <iomanip>
#include <limits>
using namespace std;
void removeCommas(string& str1, int len);
int main(int argc, char** argv)
{
string input_file = "stock.txt";
ifstream ifsInputFile(input_file.c_str());
if (ifsInputFile.is_open ()){
string strLine;
while (getline (ifsInputFile, strLine))
{
// input file stucture is below
// a single space
// the stock's symbol
// name of a NASDAQ stock
// the stock's value at close of day indicated by report date
// how much the stock's value has changed since the last
report
// how much the stock's value has changed since the last report as
a percentage
// the number of contracts traded for the day
// the price volume (current price times current volume divided by
1000)
// the report date
// the number of shares owned
stringstream ssWordsBuf (strLine);
string stock_symbol, stock_name, stock_value_close_of_day,
stock_value_since_last_report ;
string stock_value_since_last_report_percentage,
number_of_contracts, price_volume, report_date, no_of_shares;
char space = ssWordsBuf.get();
getline(ssWordsBuf, stock_symbol, '~'); //1
getline(ssWordsBuf, stock_name, '~'); //2
getline(ssWordsBuf, stock_value_close_of_day, '~'); //3
int i = stock_value_close_of_day.length();
removeCommas(stock_value_close_of_day, i);
stringstream stream_stock_value
(stock_value_close_of_day);
double stock_value = 0.0;
stream_stock_value >> stock_value;
ssWordsBuf.ignore(numeric_limits<streamsize>::max(), '~');
//4
ssWordsBuf.ignore(numeric_limits<streamsize>::max(), '~');
//5
ssWordsBuf.ignore(numeric_limits<streamsize>::max(), '~');
//6
ssWordsBuf.ignore(numeric_limits<streamsize>::max(), '~');
//7
ssWordsBuf.ignore(numeric_limits<streamsize>::max(), '~');
//8
getline(ssWordsBuf, no_of_shares, '~');
stringstream stream_stock_value1 (no_of_shares);
double shares = 0.0;
stream_stock_value1 >> shares;
cout << setw(10) << stock_symbol<< setw(40)
<< stock_name<< setw(20) << fixed <<
setprecision(2 )
<< stock_value_close_of_day<< setw(20) <<
no_of_shares << setw(20) << fixed <<
setprecision(2 ) << (stock_value * shares) ;
cout << endl;
}
ifsInputFile.close();
}
return 0;
}
void removeCommas(string& str1, int len)
{
int j = 0;
for (int i = 0; i < len; i++) {
if (str1[i] == ',') {
continue;
}
else
{
str1[j] = str1[i];
j++;
}
}
str1[j] = '\0';
}
Mr. N. Vestor owns several different stocks. Data regarding these stocks can be found in a...
Hello, I'm having trouble with the trial balance. Can someone please help me with it. I think something is wrong with the adjusted trial balance. khampton ACCOUNTING SERVICE INC Dear Newbie, Welcome to Hampton! My name is Julio Antoni, your supervisor. We believe the best way for you to get familiar with what you are going to be doing here is to throw you right in, so we are asking you to start working on the books for us right...
Santa Monica College CS 20A: Data Structures with C++ Spring 2019 Name: True/False: Circle one Assignment 1 ID: 1. True / False 2. True / False 3. True / False 4. True / False 5. True / False 6. True / False 7. True / False 8. True / False 9. True / False 10. True / False Variable and functions identifiers can only begin with alphabet and digit. Compile time array sizes can be non-constant variables. Compile time array...
QUESTION: The following 5 pictures are a part of real life AEO financial statements. Can you help me analyze the following....I need to use the liquidity, solvency, and profitability ratios to prepare a two year ratio analysis of AEO using the two most recent years on the following 5 statements pictured. Then, in your opinon what is the finanical strength and overall profitability of AEO, and why? Thank you for your help! Item 6. Selected Consolidated Financial Data. The following...
Objective: Learn basic C# Programming Language A certain automobile dealership sells fifteen different models of automobiles and employs ten salesmen. A record of sales for each month can be represented by a table, the first row of which contains the number of sales of each model by salesman 1, the second row contains the number of sales of each model by salesman 2, and so on. For example, suppose that the sales table for a certain month is the following:...
When light passes between media of different densities, it is bent or refracted. True False Flag this Question Question 2 3 pts Meniere’s disease is caused by an increase in the intraocular pressure. volume of endolymph. none of the above volume of blood. Flag this Question Question 3 3 pts An area of the retina that contains only cones, and is the site of sharpest vision, is the outer segment. inner segment. fovea. optic disc. Flag this Question Question 4...
Super stuck on a couple of questions on this scenario. Advanced Scenario 7: Mark and Barbara Matthews Directions Using the tax software, complete the tax retum, including Form 1040 and all appropri- ate forms, schedules, or worksheets. Answer the questions following the scenario. Note: When entering Social Security numbers (SSNS) or Employer identification Numbers (EINS), replace the Xs as directed, or with any four digits of your choice. Interview Notes • Mark and Barbara are married and want to file...
CASE 8 Unlocking the Secrets of the Apple iPhone in the Name of access the male San Bernardino suspect's iPhone 5c. Cook stated: Antiterrorism We are challenging the FBI's demands with the deepes respect for American democracy and a love of our country. We believe it would be in the best interest of everyone to step back and consider the implications While we believe the FBI's intentions are good, if would be wrong for the w e nt to force...
CASE 20 Enron: Not Accounting for the Future* INTRODUCTION Once upon a time, there was a gleaming office tower in Houston, Texas. In front of that gleaming tower was a giant "E" slowly revolving, flashing in the hot Texas sun. But in 2001, the Enron Corporation, which once ranked among the top Fortune 500 companies, would collapse under a mountain of debt that had been concealed through a complex scheme of off-balance-sheet partnerships. Forced to declare bankruptcy, the energy firm...