#include <iostream>
using namespace std;
//define constant
const double SERVICE_FEE = 0.015;
int main()
{
//declaring my variables
double sharesSold;
double purchasePrice;
double sellingPrice;
double amntInvested;
double amntRecieved;
double gainLost;
double totalService;
double buyService;
double sellService;
//asking for user input
cout << "How many shares did you sell?: ";
cin >> sharesSold;
cout << "What was the purchase price of each share?: $";
cin >> purchasePrice;
cout << "What was the selling price of each share?: $";
cin >> sellingPrice;
//start entering formulas to calculate service fees
sellService = (sharesSold * sellingPrice) * SERVICE_FEE;
buyService = (sharesSold * purchasePrice) * SERVICE_FEE;
totalService = (buyService + sellService);
//enter formulas to calculate total invested amount
amntInvested = (purchasePrice * sharesSold) + buyService;
//display outputs so far
cout << "The total amount you invested is: $" << amntInvested << endl;
cout << "The total amount of Service Charges is: $" << totalService << endl;
//calculate how much is gained or lost
gainLost = (sharesSold * (sellingPrice - purchasePrice)) - totalService;
if (gainLost > 0)
cout << "Total Amount Gained: $" << gainLost << endl;
else
cout <<"Total Amount Lost: $" << (gainLost*-1) << endl;
//calculate recieved amnt
amntRecieved = (sharesSold * sellingPrice) - sellService;
cout << "The total amount you recieved is: $" << amntRecieved << endl;
return 0;
}