Read the lab requests and fix my mistakes

profiledqztmq2r
cmpsc121_lab4_yang.txt

/* * main.cpp * * Created on: Mar 22, 2016 * Author: hvy5137 */ #include <iostream> #include <fstream> #include <iomanip> #include <cmath> #include <string> using namespace std; ifstream inputFile; char userInput; int main() { string name; name="Jack"; cout<< "Enter your name:"<<name<< endl; cout<< "Hello " <<name<< ", please select the service: " << 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; cin>>userInput; cout<< endl; if (userInput =='A') { double N_shares, P_shares, P_commission, A_return; int Year; double shares, price, percentage, annual, paid, commission, total_amount, worth, years; char receipt; string name; name = "Jack"; inputFile.open("sample.txt"); //Number of shares bought cout << "How many shares to be bought? "; inputFile >> N_shares; cout << N_shares <<endl; //Price/share cout << "The price per share: "; inputFile >>P_shares; cout <<"$"<<setprecision(4)<<showpoint<< P_shares<<endl; //Percent of commission cout << "Percent commission for the broker for each transaction: "; inputFile >> P_commission; cout << P_commission<<"%" <<endl; //Average Annual Return cout << "Average annual return as of percentage: "; inputFile >> A_return; cout<<setprecision(0)<< A_return<<"%"<<endl; //Years of holding stocks cout<<"How many years you will hold the stock:"; inputFile >> Year; cout << Year <<endl; inputFile.close(); //The amount paid for the stock alone (without the commission) paid=P_shares * N_shares ; //Display the Paid. cout << "The amount paid for the stock alone (without the commission) is $"<<setprecision(6)<<showpoint<<paid<< endl; //The amount of commission commission= paid * (P_commission/100); // Display commission cout<< "The commission is $" <<setprecision(5)<<showpoint<< commission << endl; //The total amount of paid (the payment for stock plus the commission) total_amount= paid + commission ; // Display Total amount cout<< "The total amount is $ "<<setprecision(6)<<showpoint<< total_amount << endl; //After X years, your shares will worth: worth= pow((1+ A_return/100), Year) * paid; cout<<"After "<<Year<<" years you shares will be worth: $"<<setprecision(7)<<worth<< endl; cout<< endl; //Receipt cout<<"Would you like a receipt? Y/N "; cout<< "______________________________________"<<endl; cin>>receipt; if(receipt =='N') { cout<<"Have a nice day!"<< endl; } else if(receipt =='Y') { cout<<"Your name:"<<name<<endl; cout<<"-------------------------------"; cout<< endl; cout<<"Total stock: "<<setw(20)<<"$ "<<setprecision(6)<<showpoint<<paid<< endl; cout<<"Commission: "<<setw(20)<<"$ "<<setprecision(5)<<showpoint<<commission<< endl; cout<<"Total Amount:"<<setw(20)<<"$ "<<setprecision(6)<<showpoint<<total_amount<< endl; cout<<"Net worth in "<<Year<<" years:"<<setw(11)<<"$ "<<setprecision(7)<<worth<< endl; } } else if(userInput =='B'||userInput =='C'||userInput =='D') { cout<<"service coming soon"<< endl; } else if(userInput == 'E') { cout<< "Thank you!"<< endl; } else { cout<<"INVALID SELCETION"<< endl; } return 0; }