Ethan O.

asked • 09/20/19

How do I get the company name to show all of it?

My output:

Enter the name of the company

Enter shares of stock

Enter purchase price

Enter sale price Company: "Still"


Expected Output (should look like)

Enter the name of the company


Enter sale price Company: "Still not a real company"





#include <iostream>

#include <iomanip>

#include <string>

using namespace std;


Expected Output



const double Commission = 0.035;


int main()

{


double PurchasePrice;

double SoldPrice;

int NumShares;

double TotalCost;

double gainLoss;

double TotalGains;

string CompName;


std::cout << std::fixed;

std::cout << std::setprecision(2);


// User inserts company name, purchase price, and the selling price

cout << "Enter the name of the company" << endl;

cin >> CompName;

cout << "Enter shares of stock" << endl;

cin >> NumShares;

cout << "Enter purchase price" << endl;

cin >> PurchasePrice;

cout << "Enter sale price" << endl;

cin >> SoldPrice;

cout << endl;


// Calculations

TotalCost = (PurchasePrice * NumShares) + (PurchasePrice * NumShares * Commission);

TotalGains = (SoldPrice * NumShares) - (SoldPrice * NumShares * Commission);

gainLoss = TotalGains - TotalCost;


// Display Company and Shares

cout << "Company: " << CompName << endl;

cout << "Shares: " << NumShares << noshowpoint << endl;

cout << endl;


cout << "Purchase/share: $" << PurchasePrice << endl;

cout << "Cost of stock: $" << PurchasePrice * NumShares << endl;

cout << "Cost of commission: $" << (PurchasePrice * NumShares) * Commission << endl;

cout << "Total cost: $" << TotalCost << endl;

cout << endl;


// Dispaly Selling Values


cout << "Sale/share: $" << SoldPrice << noshowpoint << endl;

cout << "Income from stock: $" << SoldPrice * NumShares << endl;

cout << "Cost of commission: $" << SoldPrice * NumShares * Commission << endl;

cout << "Total income: $" << TotalGains << endl;

cout << endl;


//Dispaly gains or loss

cout << "Gain or loss: $" << gainLoss << endl;



return 0;


}

1 Expert Answer

By:

Brian T. answered • 09/24/19

Tutor
5 (1)

Computer Geek and Programmer!

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.