Advertisement
Guest User

Untitled

a guest
Mar 18th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3.  
  4. using namespace std;
  5. int main()
  6. {
  7. //This program will take the values the user inputs to calculate car loan payments.
  8.  
  9. cout << "Car Loan Calculator" << endl;
  10. float price;
  11. float downPayment;
  12. float tradeIn;
  13. float loanAmt;
  14. float annualIntRate;
  15. float annualIntPercent;
  16. float monIntRate;
  17. int noMonths;
  18. float monPayment;
  19.  
  20. cout << "What is the price of the car you want to buy? ";
  21. cin >> price;
  22. cout << "If you traded in a car, please input the value of the car. If not please input 0. ";
  23. cin >> tradeIn;
  24. cout << "What is the down payment of the car you want to buy? ";
  25. cin >> downPayment;
  26. cout << "What is the interest rate for your car loan in percentage? ";
  27. cin >> annualIntRate;
  28. cout << "Would you like to make payments for 12, 24, 36, 48, or 60 months? ";
  29. cin >> noMonths;
  30.  
  31. //This while statement is to check that the users input matches all of the specifications for the calculator.
  32.  
  33. while
  34.  
  35. (price > 50, price < 50000);
  36. (tradeIn >= 0, tradeIn < price);
  37. (downPayment >= 0, downPayment < price - tradeIn);
  38. (annualIntRate >= 0, annualIntRate < 100);
  39. (noMonths = 12, noMonths = 24, noMonths = 36, noMonths = 48, noMonths = 60);
  40.  
  41. monIntRate = annualIntRate / 12;
  42. annualIntPercent = annualIntRate * 100;
  43. loanAmt = price - downPayment - tradeIn;
  44. monPayment = ( loanAmt * monIntRate ) / ( 1 - (1 + monIntRate) ^ -noMonths);
  45. cout << "The monthly payment is";
  46. cout << monPayment;
  47. system("pause");
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement