Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. void Greeting ();
  5. void Option (char* answer);
  6. void Question (float* balance, float* total, float* i, float* amount, float* goal);
  7. void Borrow (float* loan, float* totalx, float balancex, float ix, float amountx, float goalx);
  8. void info (float, float, float, float, float);
  9.  
  10. int main()
  11. {
  12. float balance, total, i, amount, goal, loan, totalx, balancex, ix, amountx, goalx;
  13. char answer;
  14.  
  15. Greeting();
  16. Option (&answer);
  17. Question(&balance, &total, &i, &amount, &goal);
  18. Borrow (&loan, &totalx, &balancex, &ix, &amountx, &goalx);
  19. info(balance, total, i, amount, goal);
  20.  
  21. system("pause");
  22. return 0;
  23. }
  24.  
  25. void Greeting()
  26. {
  27. cout<< "Welcome to the Bank of Kwantlen!"<< endl << endl;
  28. return;
  29. }
  30.  
  31. void Option (char* answer)
  32. {
  33. cout <<"Do you want to invest (i) with us or borrow (b) from us? ";
  34. cin >> answer;
  35. cout << endl;
  36. return;
  37. }
  38.  
  39. void Question (float* balance, float* total, float* i, float* amount, float* goal)
  40. {
  41. float rate;
  42.  
  43. int num;
  44. num = 5;
  45.  
  46. cout << "Enter the amount to invest annually: ";
  47. cin >> *amount;
  48. cout << "Enter the yearly percentage rate of return: ";
  49. cin >> rate;
  50. cout << "Enter the investment goal: ";
  51. cin >> *goal;
  52. cout << endl;
  53.  
  54. cout << "Year Balance Balance\n";
  55. cout << " (Jan. 1) (Dec. 31)\n";
  56.  
  57. *total = 0;
  58. *i=1;
  59. *balance = 0;
  60.  
  61. while (*total < *goal)
  62. {
  63. *balance = *total + *amount;
  64. *total = *balance *(1+(rate/100));
  65.  
  66. cout << *i << " " << *balance << " " << *total << endl;
  67. *i = *i+1;
  68. }
  69. return;
  70. }
  71. void Borrow (float* loan, float* totalx, float balancex, float ix, float amountx, float goalx)
  72. {
  73. cout <<"Enter the amount of the loan: ";
  74. cin >> loan;
  75. cout <<"Enter the annual interest rate: ";
  76. cin >> ratex;
  77. cout <<"Enter the annual payment amount: ";
  78. cin >> amountx;
  79.  
  80. cout << endl;
  81.  
  82. cout << "Year Balance Balance\n";
  83. cout << " (Jan. 1) (Dec. 31)\n";
  84.  
  85. *totalx = 0;
  86. *ix=1;
  87. *balancex = 0;
  88.  
  89. while (*totalx < *goalx)
  90. {
  91. *loanx = *totalx + *amountx;
  92. *totalx = *balancex *(1+(ratex/100));
  93.  
  94. cout << *ix << " " << *balancex << " " << *totalx << endl;
  95. *ix = *ix+1;
  96. }
  97. return;
  98. }
  99.  
  100. void info (float balance, float total, float i, float amount, float goal)
  101. {
  102. float investment;
  103. float accumulated;
  104. float final;
  105. cout << endl;
  106. i = i-1;
  107. cout << "Number of years needed to achieve investment goal: " << i << endl;
  108. investment = i * amount;
  109. cout << "Total Investment " << investment << endl;
  110. accumulated = total - investment;
  111. cout << "Total accumulated return on investment " << accumulated << endl;
  112. final = total - goal;
  113. cout << "Final balance exceeds goal by " << final << endl;
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement