Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- using namespace std;
- double stock(int shares, double purPrice, double buyComm, double salePrice, double saleComm);
- {
- double profit = ((shares * salePrice) - saleComm) - ((shares * purPrice) + buyComm);
- return profit;
- }
- int main()
- {
- int numShares;
- double salePrice, saleCommission, purchasePrice, purchaseCommission, profit_or_loss;
- while (numShares != -99)
- {
- cout << endl << "Enter -1 to get the profit." << endl;
- cout << "Number of shares purchased: ";
- cin >> numShares;
- if (numShares != -1)
- {
- cout << "Purchase Price per share: ";
- cin >> purchasePrice;
- cout << "Purchase Commission Paid: ";
- cin >> purchaseCommission;
- cout << "Sale Price per Share: ";
- cin >> salePrice;
- cout << "Sale Commission Paid: ";
- cin >> saleCommission;
- profit_or_loss = stock(numShares, purchasePrice, purchaseCommission, salePrice, saleCommission);
- }
- }
- if (profit_or_loss < 0)
- {
- cout << "That is a loss of $ " << profit_or_loss << endl << endl;
- }
- else
- {
- cout << "That is a profit of $ " << profit_or_loss << endl << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement