-
Notifications
You must be signed in to change notification settings - Fork 0
/
Assignment 2.txt
50 lines (44 loc) · 1.73 KB
/
Assignment 2.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*Student Name: Arno Dunstatter
Course Name: Programming Fundamentals
Course Number: CS1336
Section: 001
Due Date: 2/10/20
Date Completed: 2/5/20
Date Submitted: 2/5/20 */
#include <iostream>
#include <string>
using namespace std;
int main() {
//first we'll initialize and declare variables
double numShares = 1500; //number of shares purchased and sold
double initialPrice = 45.75;
double buyCommission = 0.0227;
double sellPrice = 58.75;
double sellCommission = 0.0255;
double totSellCommission, profit; //total amount spent on commission when selling the shares
double saleCostBeforeCom = initialPrice * numShares;
double totBuyCommission = buyCommission * initialPrice * numShares;
double saleBeforeCom = sellPrice * numShares;
double totSpent = saleCostBeforeCom + totBuyCommission;
double totSaleCom = sellCommission * sellPrice * numShares;
//information relevant to the purchase
cout << "Joe purchased 1500 shares of Amity Software, inc. \n";
cout << "He paid $45.75 per share, so he spent $";
cout << saleCostBeforeCom << " on the stock.\n";
cout << "He paid a 2.27% commission on the purchase, which came to $";
//calculate commission spent when buying
cout << totBuyCommission <<".\n";
//information relevant to the sale
cout << "Two weeks later Joe sold his all 1500 shares at $58.75 per share, ";
//calculate sale value before commission
cout << "which came to $" << saleBeforeCom << ".\n";
cout << "He paid a 2.55% commission on the sale, which came to $";
//calculate sale commision
cout << totSaleCom << ".\n";
//add totSaleCom to totalSpent
totSpent += totSaleCom;
//calculate and report profit
profit = saleBeforeCom - totSpent;
cout << "All said and done, Joe made $" << profit << " in profit.\n";
return 0;
}