C PROGRAMMING Below is the prompt for my homework Im confuse
C PROGRAMMING
Below is the prompt for my homework. I\'m confused on the setup but mostly if we need to add interest to the first month and if a loop is required. I had
monthlyRate = (1 / 12) * rate; //monthly interest
numMonths = (retirementAge - age) * 12;
for (i = 1; i < numMonths; ++i) {
amtOwed = (amtOwed * monthlyRate) + amtOwed - monthlyPayment;
For this program you will be determining if it is better to put as much money as you can towards your student loans before saving for retirement or if it is better to only pay the minimum payment on your loan and invest the rest.
Points to pay attention to:
Interest rates given are annual interest rates but we will assume that interest is
compounded monthly so the real rates to use will be 1 of what are given 12
We will assume that interest is compounded on our accounts before any payments or contributions are made to them.
If the user has not finished paying off all of their loans by the time they retire a warning message should be printed
Cautions about using this program for your own investment strategy
This program is assuming you would be investing your money in a Roth IRA
Turns out there is a simpler answer than this program to finding out how you
should invest. Remind me to tell you about it you finish it.
Examples:
Enter how much money you will be putting towards loans/retirement each month: 500
Enter how much you owe in loans: 40000
Enter the annual interest rate of the loans: 0.03 Enter your minimum monthly loan payment: 405.32 Enter your current age: 22
Enter how much money you will be putting towards loans/retirement each month: 1053
Enter how much you owe in loans: 50000
Enter the annual interest rate of the loans: 0.06 Enter your minimum monthly loan payment: 350 Enter your current age: 25
Enter how much money you will be putting towards loans/retirement each month: 500
Enter how much you owe in loans: 10000
Enter the annual interest rate of the loans: .02 Enter your minimum monthly loan payment: 100 Enter your current age: 18
Enter how much money you will be putting towards loans/retirement each month: bob
Enter how much money you will be putting towards loans/retirement each month: cat
Solution
printf(\"Enter how much you owe in loans\");
scanf(\"%f\",&oweloans);
printf(\"Enter the annual interest rate of the loans: \");
scanf(\"%f\",&rate);
printf(\"Enter your minimum monthly loan payment:);
scanf(\"%f\",&minmonthpay);
printf(\"enter your current age \");
scanf(%d,&age);
printf(\"Enter the age you plan to retire at:\");
scanf(%d,&agetoretire);
scanf(%f,&retpredit);
float monthlyRate = (1 / 12) * rate; //monthly interest
float numMonths = (retirementAge - age) * 12;
for (i = 1; i < numMonths; ++i) {
float amtOwed = (amtOwed * monthlyRate) + amtOwed - monthlyPayment;
if(amtloansorret<0 ||oweloans<0||annualinterest<0||minmonthpay<0)
{
return;
}
if(age<30)
{
float amounttobepaid=(totalyear-age)*12*rate;
printf(\" You should only make the minimum payments on your loan and apply
printf(\"%f\",amounttobepaid);
}
else{
}

