Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- int main()
- {
- //This program will take the values the user inputs to calculate car loan payments.
- cout << "Car Loan Calculator" << endl;
- float price;
- float downPayment;
- float tradeIn;
- float loanAmt;
- float annualIntRate;
- float annualIntPercent;
- float monIntRate;
- int noMonths;
- float monPayment;
- cout << "What is the price of the car you want to buy? ";
- cin >> price;
- cout << "If you traded in a car, please input the value of the car. If not please input 0. ";
- cin >> tradeIn;
- cout << "What is the down payment of the car you want to buy? ";
- cin >> downPayment;
- cout << "What is the interest rate for your car loan in percentage? ";
- cin >> annualIntRate;
- cout << "Would you like to make payments for 12, 24, 36, 48, or 60 months? ";
- cin >> noMonths;
- //This while statement is to check that the users input matches all of the specifications for the calculator.
- while
- (price > 50, price < 50000);
- (tradeIn >= 0, tradeIn < price);
- (downPayment >= 0, downPayment < price - tradeIn);
- (annualIntRate >= 0, annualIntRate < 100);
- (noMonths = 12, noMonths = 24, noMonths = 36, noMonths = 48, noMonths = 60);
- monIntRate = annualIntRate / 12;
- annualIntPercent = annualIntRate * 100;
- loanAmt = price - downPayment - tradeIn;
- monPayment = ( loanAmt * monIntRate ) / ( 1 - (1 + monIntRate) ^ -noMonths);
- cout << "The monthly payment is";
- cout << monPayment;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement