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;
}