Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- void Greeting ();
- void Option (char* answer);
- void Question (float* balance, float* total, float* i, float* amount, float* goal);
- void Borrow (float* loan, float* totalx, float balancex, float ix, float amountx, float goalx);
- void info (float, float, float, float, float);
- int main()
- {
- float balance, total, i, amount, goal, loan, totalx, balancex, ix, amountx, goalx;
- char answer;
- Greeting();
- Option (&answer);
- Question(&balance, &total, &i, &amount, &goal);
- Borrow (&loan, &totalx, &balancex, &ix, &amountx, &goalx);
- info(balance, total, i, amount, goal);
- system("pause");
- return 0;
- }
- void Greeting()
- {
- cout<< "Welcome to the Bank of Kwantlen!"<< endl << endl;
- return;
- }
- void Option (char* answer)
- {
- cout <<"Do you want to invest (i) with us or borrow (b) from us? ";
- cin >> answer;
- cout << endl;
- return;
- }
- void Question (float* balance, float* total, float* i, float* amount, float* goal)
- {
- float rate;
- int num;
- num = 5;
- cout << "Enter the amount to invest annually: ";
- cin >> *amount;
- cout << "Enter the yearly percentage rate of return: ";
- cin >> rate;
- cout << "Enter the investment goal: ";
- cin >> *goal;
- cout << endl;
- cout << "Year Balance Balance\n";
- cout << " (Jan. 1) (Dec. 31)\n";
- *total = 0;
- *i=1;
- *balance = 0;
- while (*total < *goal)
- {
- *balance = *total + *amount;
- *total = *balance *(1+(rate/100));
- cout << *i << " " << *balance << " " << *total << endl;
- *i = *i+1;
- }
- return;
- }
- void Borrow (float* loan, float* totalx, float balancex, float ix, float amountx, float goalx)
- {
- cout <<"Enter the amount of the loan: ";
- cin >> loan;
- cout <<"Enter the annual interest rate: ";
- cin >> ratex;
- cout <<"Enter the annual payment amount: ";
- cin >> amountx;
- cout << endl;
- cout << "Year Balance Balance\n";
- cout << " (Jan. 1) (Dec. 31)\n";
- *totalx = 0;
- *ix=1;
- *balancex = 0;
- while (*totalx < *goalx)
- {
- *loanx = *totalx + *amountx;
- *totalx = *balancex *(1+(ratex/100));
- cout << *ix << " " << *balancex << " " << *totalx << endl;
- *ix = *ix+1;
- }
- return;
- }
- void info (float balance, float total, float i, float amount, float goal)
- {
- float investment;
- float accumulated;
- float final;
- cout << endl;
- i = i-1;
- cout << "Number of years needed to achieve investment goal: " << i << endl;
- investment = i * amount;
- cout << "Total Investment " << investment << endl;
- accumulated = total - investment;
- cout << "Total accumulated return on investment " << accumulated << endl;
- final = total - goal;
- cout << "Final balance exceeds goal by " << final << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement