// Assignment 3 solution #include #include #include #include using namespace std; int main() { const string StockTicker = "WMT"; const string purchaseDate = "01/02/17"; const float investmentAmount = 10000.00; const char dollar = '$'; float cash = 0; string sellDate; float purchasePrice; float sellPrice; int numberOfShares; float sellValue; float gain; float percentGain; cout << "Enter the purchase price => "; cin >> purchasePrice; cout << "Enter the sell date (mm/dd/yy) => "; cin >> sellDate; cout << "Enter the sell price => "; cin >> sellPrice; numberOfShares = static_cast(investmentAmount/purchasePrice); cash = investmentAmount - numberOfShares * purchasePrice; sellValue = numberOfShares * sellPrice; gain = sellValue + cash - investmentAmount; percentGain = gain / investmentAmount *100; cout << setprecision(2) << fixed << endl; cout << "Stock Ticker: " << StockTicker << endl << endl; cout << "Purchase Date: " << purchaseDate << endl; cout << "Purchase Price: " << dollar << purchasePrice << endl; cout << "Number of Shares Purchased: " << numberOfShares << endl << endl; cout << "Sell Date: " << sellDate << endl; cout << "Sell Price: " << dollar << sellPrice << endl; cout << "Value of Shares Sold: " << dollar << sellValue << endl; cout << "Gain: $" << gain << endl; cout << setprecision(1); cout << "Percent Gain: " << percentGain << '%' << endl; }