dimanche 25 janvier 2015

How do you calculate interest on a loan with different rates?

I think it's obvious I don't understand. How do you tell the computer in C to decide which is the appropriate interest rate and then calculate and display it. This is the best I could come up with and I have to hand this as an assignment tomorrow. I had not clue it would be this difficult.



#include <stdio.h>
int main (void)
{
float time;
float principal;
char response[15];
float rate1, rate2,rate3,rate4;
rate1=.04,rate2=.05,rate3=.06,rate4=.07;

float SimpleInterest1;
float SimpleInterest2;
float SimpleInterest3;
float SimpleInterest4;

SimpleInterest1=principal*time*rate1;
SimpleInterest2=principal*time*rate2;
SimpleInterest1=principal*time*rate3;
SimpleInterest2=principal*time*rate4;


printf("Please enter principal\n");
scanf ("%f",&principal);
printf ("Please enter time\n");
scanf ("%f",&time);

if (principal <= 5000)
{

printf ("%f",&SimpleInterest1);
}
printf ("Do you still want the loan?\n");
scanf ("%s",response);

return 0;
}

Aucun commentaire:

Enregistrer un commentaire