Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

//Header Files #include#include #include using namespace std; I am only needing

ID: 3653617 • Letter: #

Question

//Header Files #include#include #include using namespace std; I am only needing this program to calculate for 24, 36, 48, & 60 months. I am still getting a calculation for 12 months and I am needing help on how to get it to quit calculating for 12 months. Can someone help point out where I have gone wrong? Thank You! //Main Program int main() //Declaring Variables { double price,trade,down,rate,payment,loanAmt,monIntRate,monPayment ; int noMonths; //Tell User to Enter Full Car Price cout<<"Enter car price: "; //Program Reads Car Price cin>>price; //Program will Loop Back to "Enter car price" if amount entered is less than zero while(price<0) //Price must be greater than zero {cout<<"invalid price-must be >0 "; //Enter car price again cout<<"Enter car price: "; //Program Reads Car Price cin>>price; } //Tell User to Enter Full Trade Value cout<<"Enter trade in value: "; //Program Reads Value of Trade cin>>trade; //Program will Loop Back to "Enter trade in value" if amount entered is less than zero while(trade<0) //Trade Value must be greater than zero {cout<<"invalid trade in value-must be >0 "; //Enter Trade Value Again cout<<"Enter trade in value: "; //Program Reads Value of Trade cin>>trade; } //Tell User to Enter Full Down Payment cout<<"Enter down payment: "; //Program Reads Amount Put Down on Car cin>>down; //Program will Loop Back to "Enter down payment" if amount enterd is less than zero while(down<0) //Down Payment Amount must be greater than zero {cout<<"invalid down payment-must be >0 "; //Enter Down Payment Again cout<<"Enter down payment: "; //Program Reads Amount Put Down on Car cin>>down; } //Tell User to Enter Annual Interest Rate cout<<"annual interest rate: "; //Program Reads Annual Interest Rate cin>>rate; //Program will Loop Back to "Enter annual interest rate" if amount entered is less than zero while(rate<0) //Annual Interest Rate must be greater than zero {cout<<"invalid annual interest rate-must be >0 "; //Enter Annual Interest Rate Again cout<<"annual interest rate: "; //Program Reads Annual Interest Rate cin>>rate; } //Program Calculates Information Entered monIntRate =rate/100./24.; loanAmt=price-trade-down; // cout<<"months monthly payment "; for(noMonths=24;noMonths<=60;noMonths+=24) {monPayment=(loanAmt*monIntRate)/(1.-pow(1+monIntRate,-noMonths)); cout<<noMonths<<" $"<<setprecision(2)<<fixed<<monPayment<<endl; } system("pause"); return 0; }

Explanation / Answer

In this case, in "main" your "MonPayment" array is only 4 big. This is bad because in CalcMonPayment your for loop goes from 24 to 60, which means it will be trying to access 60 elements in an array that only has 4. Judging by the fact that you are incrementing NoMonths by 12 every loop, I think your logic might be mixed up somewhere