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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
|
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;
double Principle, InterestRate, LoanTerm,MonthMort;
string name, userInput;
void mort(){
double numerator, denominator, rate;
double payments;
cout<< "Please enter the following:" << endl ;
cout<<"Principle:";
cin>> Principle;
cout<< "Interest rate:";
cin>> InterestRate;
cout<< "Loan Term:";
cin>> LoanTerm;
//caculations
rate= (InterestRate/100)/12;
payments= LoanTerm*12;
numerator= Principle*(rate* pow((1+rate), payments));
denominator= (pow((1+rate), payments))-1;
MonthMort= numerator/denominator;}
int main()
{
cout<< "What is your Name? ";
getline(std::cin, name);
cout<<endl;
cout<< "Hello " << name << ", how are you?" << endl;
cout<< endl;
cout<< "A: Investment Projection"<< endl;
cout<< "B: Retirement planning"<< endl;
cout<< "C: Mortgage"<< endl;
cout<< "D: College Fund"<< endl;
cout<< "E: Exit"<< endl;
cout<< endl;
cout <<"What are you selecting?";
cin >> userInput;
if( userInput == "A")
{
double shares, price, commission, annual, years, total, paid, NET, percentage;
string receipt;
//Number of shares bought
cout << "How many shares to be bought: ";
cin >> shares;
// Price/share
cout << "The price per share: ";
cin >> price;
//Percent of commission
cout<< "Percent commission for the broker for each transaction: ";
cin>> percentage;
//Average annual return
cout<< "Average annual return as of percentage: ";
cin>> annual;
// years held
cout<< "How many years you will hold the stock: ";
cin >> years;
cout<< "____________________________________________"<<endl;
// The amount paid for the stock alone (without the commission)
paid = shares * price;
// Display the Paid.
cout << "The amount paid for the stock alone (without the commission)"<<paid<< endl;
// The amount of the commission
commission = paid * (percentage/100);
// Display commission
cout<< "The commission is $" << commission << endl;
//The total amount of paid (the payment for stock plus the commission)
total = paid + commission;
// Display Total amount
cout<< "The total amount is $: "<< total << endl;
//After FIVE years, your shares will worth:
NET = pow(annual/100, years);
cout<<"Atfer "<< years<<" your shares will be worth: "<< NET<< endl;
cout<< endl;
cout<< "Would you like a reciept?";
cin>> receipt;
cout<< "______________________________________"<<endl;
if( receipt == "Y")
{
cout<< "Your Name:"<<name<<endl;
cout<< "-------------------------------------"<< endl;
cout<< "Total Stock:"<<setw(15)<< paid<< endl;
cout<< "Commission:"<< setw(14)<< commission<< endl;
cout<< "Total amount:"<<setw(14)<<total<< endl;
cout<< "Net worth in "<< years<<"years:"<<setw(12)<< NET<< endl;
}
else if (receipt == "N")
{
cout<< "Have a nice day"<< endl;
}
}
else if (userInput== "B")
{
throw;
}
else if (userInput=="C")
{
mort();
string Answer;
cout<< "Hello "<< name<<endl;
cout<< "----------------------------------"<< endl;
//display
cout<< "Principle:"<<setw(16)<< Principle<< endl;
cout<< "Interest Rate:"<<setw(9)<< InterestRate<< endl;
cout<<"Loan Term:"<<setw(12)<<LoanTerm<<endl;
cout<<"Monthly Morgage is:"<<setw(8)<<MonthMort<< endl;
cout<< "Would you like to go back to the menu?"<< endl;
cout<<"(Y/N)";
cin>>Answer;
if (Answer== "Y"||"y") {
main();
}
else if(Answer == "N")
{
cout<< "Thank You have a nice day";\
}
if(userInput== "D") {
cout<< "service will be coming soon";
}
else if (userInput== "E"|| "e"){
cout<< "Have a nice day!";
}
else{
cout<<"INVALID SELCETION";
}
}}
|