All pastes #383031 Raw Edit

Untitled

public text v1 · immutable
·published 2007-03-06 02:00 UTC
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;

double Get_NumShares();
double Get_SalePrice();
double Get_SaleCom();

int main()
{
    char Again = 'n';

do {
   NumShares = Get_NumShares();
   SalePrice = Get_SalePrice();
   PurchasePrice = Get_PurchasePrice();
   SaleCom = Get_SaleCom();
   PurchaseCom = Get_PurchaseCom();
   TradeProfit = ((NumShares * SalePrice) - SaleCom) - ((NumShares * PurchasePrice) + PurchaseCom);
   OverallProfit += TradeProfit;

   DisplayTrade(a whole bunch of vars here); // <- lol

   cout << "Wanna try again? (y/n)";
   cin >> Again;
} while(Again == 'y');
}

double Get_NumShares()
{
    int NumShares = 0;
    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 = 0;
    do
    {
    cout << "What is the share 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;
};