Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple program.. need help

Status
Not open for further replies.

j0hnb

IS-IT--Management
Aug 31, 2004
11
0
0
US
I am writting a simple program using loops to figure out credit card dept and how long it will take to pay off your card with a minimum payment. How would I make it so when I calculate the months that it would take to payoff your dept that it rounds up one month. Thanks for your help.
-John
 
thanks.. alright.. now I have another question.. since this is a program for credit card dept it I will be calculating the amount of months it will take to pay off.. but credit cards have a yearly intrest rate, so how would I add that rate in depending on the minimum payments?
 
compounded when?? aww shucks rather than pretending I know all about interest... how about someone who does know what they're talking about


if that doesn't help i'll try & clear things up more but before i do help further you have to post code you produced & what the errors are.
 
This is the code I have written.. I have written everything execpt the calculations so far...

#include <stdio.h>

int main(void)
{
int balance, interest, min_payment_one, min_payment_two;
float months_one, months_two, months_reduced;

/*Input for balance, interest and min_payment printing of lines 1-6*/

printf(&quot;Debt Analysis Program:\n&quot;);
printf(&quot;----------------------\n\n&quot;);
printf(&quot;Enter credit card's current balance: &quot;);
scanf(&quot;%d&quot;, &balance);
printf(&quot;\nEnter annual intrest rate (as decimal): &quot;);
scanf(&quot;%d&quot;, &interest);
printf(&quot;\nEnter minimum payment: &quot;);
scanf(&quot;%d&quot;, &min_payment_one);

/*Calculations for months*/









/*printing of lines 7-12 and scanning of min_payment_two*/

printf(&quot;\n\nIt will take %f months to payoff this card with this minimum payment.\n\n&quot;, months_one);
printf(&quot;Try Increasing your payment by at lease $10...\n\n&quot;);
printf(&quot;New minimum payment: &quot;);
scanf(&quot;%d, &min_payment_two);

/*printing of lines 13-17*/

printf(&quot;\nNow it will take %f months to payoff this credit card.\n\n&quot;, months_two);
printf(&quot;You would reduce your load period by %f months with the new minimum payment.\n\n&quot;, months_reduced);
return 0;
}
 
program update...

#include <stdio.h>

int main(void)
{
int balance, interest, min_payment_one, min_payment_two, balance_two, years, interest_multiplier, interest_addition;
float months_one, months_two, months_reduced;

/*Input for balance, interest and min_payment printing of lines 1-6*/

printf(&quot;Debt Analysis Program:\n&quot;);
printf(&quot;----------------------\n\n&quot;);
printf(&quot;Enter credit card's current balance: &quot;);
scanf(&quot;%d&quot;, &balance);
printf(&quot;\nEnter annual intrest rate (as decimal): &quot;);
scanf(&quot;%d&quot;, &interest);
printf(&quot;\nEnter minimum payment: &quot;);
scanf(&quot;%d&quot;, &min_payment_one);

/*Calculations for months_one*/

months_one = balance / min_payment_one;
years = months_one / 12;
years = ceil(years);
interest_multiplier = years * interest;
interest_addition = balance * interest_multiplier;
balance_two = interest_addition + balance;
months_one = balance_two / min_payment_one;
months_one = ceil(months_one);

/*printing of lines 7-12 and scanning of min_payment_two*/

printf(&quot;\n\nIt will take %f months to payoff this card with this minimum payment.\n\n&quot;, months_one);
printf(&quot;Try Increasing your payment by at lease $10...\n\n&quot;);
printf(&quot;New minimum payment: &quot;);
scanf(&quot;%d, &min_payment_two);

/*calculations for months_two and months_reduced*/

months_two = balance / min_payment_two;
years = months_two / 12;
years = ceil(years);
interest_multiplier = years * interest;
interest_addition = balance * interest_multiplier;
balance_two = interest_addition + balance;
months_two = balance_two / min_payment_two;
months_two = ceil(months_one);

months_reduced = months_one - months_two;

/*printing of lines 13-17*/

printf(&quot;\nNow it will take %f months to payoff this credit card.\n\n&quot;, months_two);
printf(&quot;You would reduce your load period by %f months with the new minimum payment.\n\n&quot;, months_reduced);
return 0;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top