Hello I am about done with this challenge but the cost is not changing when I'm trying to display all of the array. Here is my challenge to sum up the problem.
Write a program that uses a structure to store the following data about a car dealership:
Make
Model
Year
Cost
The program should use an array of at least 5 structures. It should let the user enter data into the array,
calculate the monthly payment with an interest rate of 7% for 36 months and display all the data stored in
the array.
Use the following formula
x = (1+Rate/12)
monthlyPayment = (Cost * (Rate / 12)) / (1 - pow(x,-36))
The problem is I can't put the monthly payments part of the structure but it needs to change for every car. What is another way of doing this and why is the cost not changing?
The problem is I can't put the monthly payments part of the structure
I'm sorry, I'm having trouble understanding that sentence. Are you saying you can't change the structure declaration?
Your payment amount is not changing because when you exit the loop at line 52, monthlyPayment contains the last one calculated at line 49.
If you can't include monthlyPayment as part of the struct, then there is no point in calculating it at line 49 because it just gets overlaid by the next iteration of the loop. You should move the calculation at lines 48-49 to after line 64.