Answer to Question #246738 in C++ for Lauren

Question #246738

You are to write a C++ program to calculate the monthly car payment(s) for a customer.  You have probably read ahead in your textbook and know that it would be really neat to use functions for this task.  Unfortunately, you have not had functions yet and you must resort to a linear straight-line program.   (In other words, you are NOT to use functions.)  As much as possible you are to develop the code as modular building blocks.  You are encouraged to use functional decomposition to design your program.  You are to USE NO GLOBAL VARIABLES in your work. You should manually calculate some values to ensure that your program is working correctly.




1
Expert's answer
2021-10-05T13:23:49-0400
#include <iostream>
#include <cmath> 


using namespace std;


int main()
{


	double price;
	double downPayment;
	double annualInterestRate;
	double years;
	double annualIncome;
	double monthlyPayment;
	double principal;
	double monthlyInterest;
	double numberOfMonths;
	double monthlyIncome;


	cout << "Enter a car price: " ;
	cin>> price;
	cout << "Enter the down payment: " ;
	cin>> downPayment;
	cout << "Enter the annual interest rate of the loan: ";
	cin>> annualInterestRate;
	cout << "Enter the leght of the loan in years: ";
	cin>> years;
	cout << "Enter th annual income ";
	cin>>annualIncome;
	principal = price - downPayment;
	annualInterestRate = annualInterestRate/100;
	monthlyInterest = annualInterestRate / (12 * 100);
	numberOfMonths = years * 12;
	monthlyIncome = annualIncome/12;
	monthlyPayment = principal *  (monthlyInterest/(1 - (pow(1 + monthlyInterest, -numberOfMonths))));
	cout << "Monthly payment = " <<monthlyPayment;




	cin>>monthlyPayment;
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS