rendered paste body#include <iostream>
using namespace std;
/*
int NumShares = 0;
double SalePrice = 0;
double PurchasePrice = 0;
double SaleCom = 0;
double PurchaseCom = 0;
double TradeProfit = 0;
double OverallProfit = 0;
*/
// Variables for the function calls
int Get_NumShares();
double Get_SalePrice();
double Get_SaleCom();
double Get_PurchasePrice();
double Get_PurchaseCom();
int main()
{
// Variavles defined
int NumShares = 0;
double SalePrice = 0;
double PurchasePrice = 0;
double SaleCom = 0;
double PurchaseCom = 0;
double TradeProfit = 0;
double OverallProfit = 0;
char Again = 'n';
do {
// do loop so the user can run it as many times as s/he wants
NumShares = Get_NumShares();
SalePrice = Get_SalePrice();
PurchasePrice = Get_PurchasePrice();
SaleCom = Get_SaleCom();
PurchaseCom = Get_PurchaseCom();
TradeProfit = ((NumShares * SalePrice) - SaleCom) - ((NumShares * PurchasePrice) + PurchaseCom);
OverallProfit += TradeProfit;
cout << "Do you want to try again? (y/n) ";
cin >> Again;
cout << "Your total from this trade is: " << TradeProfit << endl;
} while((Again == 'y') || (Again = 'Y'));
// outputs so the user knows everything they have entered
// and the outcomes of their dumb trades
// buy google stock and microsoft!! FTW
cout << "Your Number of shares entered is: " << NumShares << endl;
<< "Your Purchase Price entered is: " << PurchasePrice << endl;
<< "Your Purchase Commissions entered is: " << PurchaseCom << endl;
<< "Your Sales Commissions entered is: " << SaleCom << endl;
<< "Your Sales Price entered is: " << SalePrice << endl;
<< "Your cumulative total of trades is: " << OverallProfits << endl;
}
int Get_NumShares()
{
int NumShares;
do
{
cout << "What is the share price? ";
cin >> SalePrice;
if (SalePrice < 0)
cout << "Sale price must be > 0. ";
} while (NumShares == 0);
return NumShares;
};
double Get_SalePrice()
{
double SalePrice;
do
{
cout << "What is the sale price? ";
cin >> SalePrice;
if (SalePrice < 0)
cout << "Sale price must be > 0. ";
} while (SalePrice == 0);
return SalePrice;
};
double Get_SaleCom()
{
double SaleCom;
do
{
cout << "What is the sales commission? ";
cin >> SaleCom;
if (SaleCom <= 0)
cout << "Sale commission mus be >= 0. ";
} while (SaleCom == 0);
return SaleCom;
};
double Get_PurchasePrice()
{
double PurchasePrice;
do
{
cout << "What is the purchase price? ";
cin >> PurchasePrice;
if (PurchasePrice < 0)
cout << "Purcahse Price muse be > 0. ";
} while (PurchasePrice == 0);
return PurchasePrice;
};
double Get_PurchaseCom()
{
double PurchaseCom;
do
{
cout << "What is the purchase commission? ";
cin >> PurchaseCom;
if (PurchaseCom <= 0)
cout << "Purcahse commission muse be > 0. ";
} while (PurchaseCom == 0);
return PurchaseCom;
};
/*
ERRORS:
3.5.07.cpp(64) : error C2065: 'SalePrice' : undeclared identifier
3.5.07.cpp(55) : error C2143: syntax error : missing ';' before '<<'
^^ times five
*/