Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.80 KB | None | 0 0
  1. /******************************************************************************
  2. * GROUP PROJECT *
  3. * LEADER: Jared Cabrera *
  4. * MEMBERS : Jezreel Salinas, Franco Miranda, Mauricio Alvarez *
  5. Arturo Morales, Dennis De Jesus *
  6. * @Date: November 16, 2017 *
  7. ******************************************************************************
  8. */
  9. #include <iostream>
  10. #include <iomanip>
  11. #include <cmath>
  12. #include <cstdlib>
  13. #include <windows.h>
  14.  
  15. using namespace std;
  16. void loadmenu();
  17. int checkChoice(int&);
  18. void printPay(double&,double&,double&,double&,double&);
  19. void inputLoanAmount(double&);
  20. void inputInterest (double&);
  21. void inputMonthlyPayments (double&);
  22. void numPayments (double, double, double, int&);
  23. void loanPayments(double&, double&, double&, double&);
  24.  
  25. int main()
  26. {
  27. int choice;
  28. double A, B, C, D, E;
  29. int F;
  30.  
  31. HANDLE screen = GetStdHandle(STD_OUTPUT_HANDLE);
  32. SetConsoleTextAttribute(screen, 10);
  33. cout << "$$\\ $$$$$$\\ $$$$$$\\ $$\\ $$\\ $$$$$$\\ " << endl;
  34. cout << "$$ | $$ __$$\\ $$ __$$\\ $$$\\ $$ |$$ __$$\\" << endl;
  35. cout << "$$ | $$ / $$ |$$ / $$ |$$$$\\ $$ |$$ / \\__|" << endl;
  36. cout << "$$ | $$ | $$ |$$ __$$ |$$ \\$$$$ | \\____$$\\ " << endl;
  37. cout << "$$ | $$ | $$ |$$ | $$ |$$ |\\$$$ |$$\\ $$ |" << endl;
  38. cout << "$$$$$$$$\\ $$$$$$ |$$ | $$ |$$ | \\$$ |\\$$$$$$ |" << endl;
  39. cout << "\\________|\\______/ \\__| \\__|\\__| \\__| \\______/ " << endl;
  40.  
  41. SetConsoleTextAttribute(screen, 15);
  42. cin.get();
  43.  
  44. do{
  45. cout << "\n\n" << endl;
  46. loadmenu();
  47. cout << setw(10) << " " << "Enter your choice: ";
  48. cin >> choice;
  49. checkChoice(choice);
  50.  
  51. switch(choice){
  52. case 1: {
  53. loanPayments(A,B,C,D);
  54. cout << setw(10) << " ";
  55. system("pause");
  56. system("cls");
  57. break;
  58.  
  59. }
  60. case 2: {
  61. printPay(A, B, C, D, E);
  62. cout << setw(10) << " ";
  63. system("pause");
  64. system("cls");
  65. break;
  66. }
  67. case 3: {
  68. inputLoanAmount(A);
  69. inputInterest(B);
  70. inputMonthlyPayments(C);
  71. numPayments(A, B, C, F);
  72. cout << setw(10) << " ";
  73. system("pause");
  74. system("cls");
  75. break;
  76. }
  77. case 4: {
  78. cout << setw(10) << " " << "Thank You For Using Me" << endl;
  79. exit(1);
  80. break;
  81. }
  82. }
  83. }while(choice != 4);
  84. return 0;
  85. }
  86.  
  87. /******************************************************************************
  88. * loadmenu() function *
  89. * - This function loads and prints up the main menu *
  90. * *
  91. ******************************************************************************
  92. */
  93. void loadmenu(){
  94.  
  95. cout << setw(10) << " " << "__________________________________" << endl;
  96. cout << setw(10) << " " << " LOAN AND SAVINGS PROGRAM " << endl;
  97. cout << setw(10) << " " << "__________________________________" << endl;
  98. cout << endl;
  99. cout << setw(10) << " " << "1. Find Monthly Loan Payments" << endl;
  100. cout << setw(10) << " " << "2. Print out a Loan Payback List" << endl;
  101. cout << setw(10) << " " << "3. Number of Payments" << endl;
  102. cout << setw(10) << " " << "4. EXIT Program" << endl;
  103. cout << setw(10) << " " << "__________________________________" << endl;
  104. cout << endl;
  105.  
  106. }
  107.  
  108. /******************************************************************************
  109. * checkChoice() function *
  110. * - This function check if the input choice is not less than 1 or 4 *
  111. * *
  112. ******************************************************************************
  113. */
  114. int checkChoice(int &choice){
  115.  
  116. while (choice < 1 || choice > 4){
  117. cout << setw(10) << " " << "Re-Enter a Number 1-4: ";
  118. cin >> choice;
  119. }
  120.  
  121. return (choice);
  122. }
  123.  
  124.  
  125.  
  126. /******************************************************************************
  127. * printPay() function *
  128. * - This function print out a loan progression showing how much you have *
  129. * paid and what's left on the loan. *
  130. ******************************************************************************
  131. */
  132. void printPay(double &L, double &yInt,double &n,
  133. double &monthlyPayment, double &balance)
  134. {
  135. double mInt;
  136. cout << setw(10) << " " <<"Enter Loan Amount: ";
  137. cin >> L;
  138. cout << setw(10) << " " << "Enter Yearly Interest-Rate: ";
  139. cin >> yInt;
  140. cout << setw(10) << " " << "Enter the Number of Monthly Payments: ";
  141. cin >> n;
  142. cout << setw(10) << " " << "Enter Monthly Payment: ";
  143. cin >> monthlyPayment;
  144.  
  145.  
  146. cout << setw(10) << " " << "----------------------"
  147. << "---------------------------" << endl;
  148. cout << setw(10) << " " << "Payment No." << setw(4)
  149. << " " << "Total Paid" << setw(6) << " " << "Left to Pay" << endl;
  150. cout << endl;
  151. cout << setw(10) << " " << "----------------------"
  152. << "---------------------------" << endl;
  153.  
  154. mInt = (yInt/100)/12;
  155. cout << fixed << setprecision(2);
  156. for(int i = 1; i <= n; i++){
  157. balance = (L*pow(1 + mInt, i)) - (monthlyPayment / mInt)
  158. *(pow(1 + mInt, i) - 1);
  159.  
  160.  
  161. cout << setw(13) << i << ":" << setw(18) << right
  162. << monthlyPayment*i << setw(18) << balance << endl;
  163. }
  164. cout << endl;
  165. }
  166.  
  167. /******************************************************************************
  168. * inputLoanAmount() function *
  169. * - This function out a loan progression showing how much you have *
  170. * paid and what's left on the loan. *
  171. ******************************************************************************
  172. */
  173. void inputLoanAmount(double& loanAmount){
  174. cout << setw(10) << " " << "Enter Loan Amount: ";
  175. cin >> loanAmount;
  176.  
  177. while (loanAmount < 0){
  178. cout << setw(10) << " " << "Enter Loan Amount: ";
  179. cin >> loanAmount;
  180. }
  181. }
  182. void inputInterest(double& interest){
  183. cout << setw(10) << " " << "Enter Monthly Interest: ";
  184. cin >> interest;
  185.  
  186. while (interest < 0){
  187. cout << setw(10) << " " << "Enter Monthly Interest: ";
  188. cin >> interest;
  189. }
  190. interest = (interest / 100) / 12;
  191.  
  192. }
  193. void inputMonthlyPayments(double& monthlyPayments){
  194. cout << setw(10) << " " << "Enter Monthly Payments: ";
  195. cin >> monthlyPayments;
  196.  
  197. while (monthlyPayments < 0){
  198. cout << "Enter Monthly Payments: ";
  199. cin >> monthlyPayments;
  200. }
  201. }
  202. void numPayments(double A, double B, double C, int& F){
  203. cout << endl;
  204. F = (- log(1 - ((B * A) / C))) / (log(1 + B));
  205. cout << fixed << setprecision(2);
  206. cout << setw(10) << " " << "$" << C << " Requires " << F
  207. << " Payments" << endl;
  208. }
  209.  
  210. void loanPayments(double& A, double& B, double& C, double& D)
  211. {
  212. cout << setw(10) << " " << "Enter Loan Amount: ";
  213. cin >> A;
  214. cout << setw(10) << " " << "Enter Interest Rate: ";
  215. cin >> C;
  216. cout << setw(10) << " " << "Enter Number of Payments: ";
  217. cin >> B;
  218.  
  219. C = C / 100;
  220.  
  221. D = ((C/12)*A)/(1-pow((1+C/12),-B));
  222. cout << setw(10) << " " << "Monthly Payment: $" << D << endl;
  223.  
  224. cout << endl;
  225. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement