All pastes #383076 Raw Edit

Anonymous

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

// 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 Sales Commissions entered is: " << SaleCom << endl;
    << "Your Purchase Commissions entered is: " << PurchaseCom << endl;
    << "Your cumulative total of trades is: " << OverallProfits << endl;
}

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



/*
ERRORS:
------ Rebuild All started: Project: jerod.call.3.5.07, Configuration: Debug Win32 ------
Deleting intermediate and output files for project 'jerod.call.3.5.07', configuration 'Debug|Win32'
Compiling...
jerod.call.3.5.07.cpp
d:\homework-\current\cmpsc.101.progmn\programs\hw3.5.07\jerod.call.3.5.07\jerod.call.3.5.07\jerod.call.3.5.07.cpp(51) : error C2143: syntax error : missing ';' before '<<'
d:\homework-\current\cmpsc.101.progmn\programs\hw3.5.07\jerod.call.3.5.07\jerod.call.3.5.07\jerod.call.3.5.07.cpp(52) : error C2143: syntax error : missing ';' before '<<'
d:\homework-\current\cmpsc.101.progmn\programs\hw3.5.07\jerod.call.3.5.07\jerod.call.3.5.07\jerod.call.3.5.07.cpp(53) : error C2143: syntax error : missing ';' before '<<'
d:\homework-\current\cmpsc.101.progmn\programs\hw3.5.07\jerod.call.3.5.07\jerod.call.3.5.07\jerod.call.3.5.07.cpp(54) : error C2143: syntax error : missing ';' before '<<'
d:\homework-\current\cmpsc.101.progmn\programs\hw3.5.07\jerod.call.3.5.07\jerod.call.3.5.07\jerod.call.3.5.07.cpp(58) : error C2556: 'double Get_NumShares(void)' : overloaded function differs only by return type from 'int Get_NumShares(void)'
        d:\homework-\current\cmpsc.101.progmn\programs\hw3.5.07\jerod.call.3.5.07\jerod.call.3.5.07\jerod.call.3.5.07.cpp(15) : see declaration of 'Get_NumShares'
d:\homework-\current\cmpsc.101.progmn\programs\hw3.5.07\jerod.call.3.5.07\jerod.call.3.5.07\jerod.call.3.5.07.cpp(58) : error C2371: 'Get_NumShares' : redefinition; different basic types
        d:\homework-\current\cmpsc.101.progmn\programs\hw3.5.07\jerod.call.3.5.07\jerod.call.3.5.07\jerod.call.3.5.07.cpp(15) : see declaration of 'Get_NumShares'
d:\homework-\current\cmpsc.101.progmn\programs\hw3.5.07\jerod.call.3.5.07\jerod.call.3.5.07\jerod.call.3.5.07.cpp(63) : error C2065: 'SalePrice' : undeclared identifier
Build log was saved at "file://d:\HOMEWORK-\current\cmpsc.101.progmn\programs\hw3.5.07\jerod.call.3.5.07\jerod.call.3.5.07\Debug\BuildLog.htm"
jerod.call.3.5.07 - 7 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
*/