#include #include using namespace std; // Read input like // Mary J. Smith // Does $72 deposited monthly at 5.5% for 2 years save $1500? // produce output like: // Ending balance = $1830.57. Mary the target is met - buy the car! // or // Ending balance = $869.037. John the target is not met - pick a cheaper car! int main() { string fname, mname, lname; string junkstr; char junkch; int deposit; int years; double interest; int goal; // Read in name cout << "Enter name: "; cin >> fname >> mname >> lname; // Read in parameters cout << "Enter command: "; cin >> junkstr >> junkch >> deposit; // Does $72 cin >> junkstr >> junkstr >> junkstr >> interest >> junkch; cin >> junkstr >> years >> junkstr; // for 2 years cin >> junkstr >> junkch >> goal >> junkch; // save $1500? // Initialization step double month_rate = interest * .01 / 12; //get monthly rate int total_months = years * 12; int count = 1; double total = 0; // no money to start // Loop over months to add new money and calc interest while (count <= total_months) { total = total + deposit; double month_interest = total * month_rate; total = total + month_interest; count = count + 1; } // Did she/he save enough? if (total >= goal) { cout << "Hurray!"; } else { cout << "Save more!"; } // Output cout << endl; cout << "You saved: " << total << endl; return 0; }