Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Coding Problems: Write a program that reads in the name of a company. Since the company name can contain spaces in the name you

C++ Coding Problems: Write a program that reads in the name of a company. Since the company name can contain spaces in the name you need to use getline to read the data into a string. Next you will read in the number of shares of stock, a stock purchase price, and a stock sale price. The number of shares will always be an integer value. With this data calculate the total amount required to purchase the stock. You also need to calculate the commission that has to be paid to the stockbroker. The stockbroker commission will be 2.5% of the amount required to purchase the stock. **Note: the commission percentage should be put into a const double variable that you will use in your calculations. Output the name of the company, the cost of a share of stock, the total amount required to pay for the stock (not including the commission), the commission, and the total cost of the stock (including the commission). Next calculate the amount of income you will get when you sell the stock for the stock sales price. You also need to calculate the cost of the commission to the stockbroker for the sale of the stock. Again this will be 2.5% of the money you get for selling the stock. Output the price of one share of stock, the amount of money you get from the sale (before the commission is paid), the amount of the commission, and the amount of money you get from the sale after you have paid the commission to the stockbroker. All of the money amounts should be output in a fixed format with two digits to the right of the decimal point. Final calculate the difference between what you paid for the stock (including the commission), and what you received when you sold the stock (less the commission). This number will be negative if you have lost money. Here is some sample input data: image text in transcribed This is what I have so far, kinda mess up for this program.

#include

#include

using namespace std;

int main()

{

cout

string company;

getline(cin, company);

int numshares = 1000; int cost_of_comission=0;

cout

double purchase_price;

cin >> purchase_price;

double sale_price;

cin >> sale_price;

double Income_from_stock = numshares * purchase_price;

double commission = Income_from_stock * 0.025;

double total_cost = Income_from_stock + cost_of_comission;

cout

cout

cout

double Income = numshares * sale_price;

cout

commission = Income_from_stock * 0.025;

cout

Income = Income_from_stock - commission;

cout

double profit = Income - total_cost;

cout

return 0;

}

Acme Software, Inc. 1000 45.50 56.90 The output from the above input will be: Company: Acme Software, Inc Shares: 1000 Purchase/share: $45.50 cost of stck: $45500.00 Cost of commission: $1137.50 Total cost: $46637.50 Sale/share: $56.90 Income from stock: $56900.00 Cost of commission: $1422.50 Total income: $55477.50 Gain or loss: $8840.00

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

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

3-25. Did the sender choose an appropriate medium for the message?

Answered: 1 week ago