Trouble with a car loan program

I am new here but have been looking over things on the site for help in my class.

I have this program due later tonight. I have been trying to get it done without any help but i really do not know where to start. I know that it requires 3 different functions plus the main one. We did not do much with functions in my class so i think that is why it is so difficult. Any help would be great. I dont know where to start with this one. This is the assigment. I dont expect someone to do it for me but just some help.


Car Loan Program

Write a C++ program that reads in financial input from a customer and determines if a customer qualifies for a car loan. The program should print whether the customer is eligible or not and also print the calculated monthly payment.

The best way to solve this program is to write each function and compile each function separately. You will need a function to:

get input:
what are the parameters?
are the parameters aliases or values?
what is the return value?
calculate the monthly payment:
what are the parameters?
are the parameters aliases or values?
what is the return value?
determine if the user is qualified to buy the car
what are the parameters?
are the parameters aliases or values?
what is the return value
main( ) – this function calls the other functions and prints if the users is quailified or not AND prints the monthy payment

Input- this is done in a function, not main( )!
cost of the car
down payment amount customer will make
annual interest rate as a percent (like 12% not .12)
customer annual income
number of years of the life of the loan (1 year, 3 years, 5 years…)

Output- this is done in main( )
A message stating if the user is eligible or ineligible and the
monthly car loan payment.

A customer is eligible if his/her monthly income is at least four times the calculated monthly payment on the loan.

Use three functions in addition to main( ).

A function to read and validate all the input (values must be > 0)

A function that takes in as parameters the down payment, the annual interest rate, life of the loan in years, and the cost of the car, and returns the monthly payment.

A function that takes in as parameters the monthly payment and the annual income and returns true if the customer qualifies and false if the customer does not qualify.

The only functions that perform input/output operations (cin and cout) are the functions to read and validate input and main( ) which will print the final message to the customer.

This is the formula to compute the monthly payment:


MP = P * (J/(1 – ((1 + J) -N) ) ) //1 this is a one not an i
• MP = monthly payment
P = principal, the amount of the loan (car price – down payment)
• I = the annual interest rate (from 1 to 100 percent like 3 or 5)
• L = length, the length (in years) of the loan, or at least the length over which the loan is amortized. (like 5 years, 3 years…)
The following assumes a typical conventional loan where the interest is compounded monthly. First I will define two more variables to make the calculations easier:
• J = monthly interest in decimal form = I / (12 x 100)
• N = number of months over which loan is amortized = L x 12

You will need to use the the built in pow( ) function for the exponent.

This is how to use the pow( ) function.

answer = pow(2,3); //will result in answer being 23, which is 8





again any help would be great
We won't do your homework for you. Paste some of the code you have worked on so far and you'll find many others will help you out. But you can't just ask a whole homework question.
I am not asking for my homework to be done for me. Just some help getting started. I dont know what my functions should be and the parameters. I can understand why you would think that and that is why i didnt want to ask on here. but i did not have anywhere else to go.

but here

#include <iostream>

using namespace std;

double getInfo() //Not sure if this should be my first function or not

int main ()

float carCost;
float downPayment;
float annualIncome;
float loanLife;
float interestRate

cout << "Please enter the total cost of the car you are buying." << endl;
cin >> carCost;

cout << "Please enter the down payment you will be putting on the car." << endl;
cin >> downPayment;

cout << "Please enter you annual income" << endl;
cin >> annualIncome;

cout << "Please enter how long you would like you loan to be, either 1, 3, or 5 years." << endl;
cin >> loanLife;

cout << "Please enter the interest rate for the loan" << endl;
cin >> interestRate;

Ok thats a good start.
You are told that you will need the pow() function so include <cmath> header file.
Next put some { } bounds within main and include at the end of main but inside } system("pause"); and return 0; Note system("pause"); is not the best way of holding the DOS screen open so that you can read the output but it will do for now.
Now enter a ; after your getInfo() declaration
Now write the implementation of getInfo() by transfering all the cout and cin statements in main() to within {} in getInfo(). This is a stated requirement which at first sight contravenes basic C++ principles.
The problem is what do you return from this function? carCost?, downPayment?, annualIncome? etc. You should only return one(1).
You have probably been told that a function should do one thing well not 5 things. So how are you going to get round your instructers direction to only use three(3) functions outside of main() and at the same time only do one job well inside each function? Also it doesn`t ring too true to offer the applicant the selection of interest rate does it? Short of five(5) separate getInfo() functions (against rules) you could use an array inside a for loop within the single getInfo() function to get and store the 5 pieces of data. You could then return array_data[]
I'm sure some of the more experienced people will assist with these imponderables. Please post your revised code to give them a start.
hth's
Topic archived. No new replies allowed.