#include <stdio.h>
#include <math.h>
void Danli ();
void Fuli ();
void Getprincipal ();
void GetYear ();
void Getyearrate ();
void Getmutualfund ();
Double p,i,f;
int n;
Main ()
{
int num=0;
while (1) {
printf ("\t\t\t|************ Compounding calculator ************|\n");
printf ("\t\t\t|------------0. Exit calculation------------|\n");
printf ("\t\t\t|------------1. Simple interest----------------|\n");
printf ("\t\t\t|------------2. Compounding----------------|\n");
printf ("\t\t\t|------------3. Calculation of principal------------|\n");
printf ("\t\t\t|------------4. Estimated------------|\n");
printf ("\t\t\t|------------5. Estimated annual rate of return--------|\n");
printf ("\t\t\t|------------6. Fixed investment income calculation----|\n");
printf ("\t\t\t|----------------------------------|\n");
printf ("Please enter select:");
scanf ("%d", &num);
Switch (NUM)
{
Case 0:
return 0;
Case 1:
Danli ();
Break
Case 2:
Fuli ();
Break
Case 3:
Getprincipal ();
Break
Case 4:
GetYear ();
Break
Case 5:
Getyearrate ();
Break
Case 6:
Getmutualfund ();
Break
Default
return 0;
}
}
}
void Danli ()
{
printf ("Please enter the Principal:");
scanf ("%lf", &p);
printf ("Please enter annual interest rate (percentage):");
scanf ("%lf", &i);
printf ("Please enter storage life:");
scanf ("%d", &n);
f = p+p* (i/100) *n;
printf ("Simple Interest Final value:%0.2lf\n", f);
}
void Fuli ()
{
printf ("Please enter the Principal:");
scanf ("%lf", &p);
printf ("Please enter annual interest rate (percentage):");
scanf ("%lf", &i);
printf ("Please enter storage life:");
scanf ("%d", &n);
f = p* (Pow (1+i/100,n));
printf ("End value of compounding:%0.2lf\n", f);
}
void Getprincipal ()
{
printf ("Please enter the target amount:");
scanf ("%lf", &f);
printf ("Please enter the target interest rate (percentage):");
scanf ("%lf", &i);
printf ("Please enter the target age:");
scanf ("%d", &n);
p = F/pow (1+ (i/100), n);
printf ("Principal to be invested:%0.2lf\n", p);
}
void GetYear ()
{
printf ("Please enter Benli and:");
scanf ("%lf", &f);
printf ("Please enter annual rate of return (percentage):");
scanf ("%lf", &i);
printf ("Please enter the Principal:");
scanf ("%lf", &p);
for (n=1;; n++)
{
if (p* (Pow ((1+i/100), n)) >=f)
{
printf ("Minimum Life:%d\n\n", N);
Break
}
}
}
void Getyearrate ()
{
printf ("Please enter Benli and:");
scanf ("%lf", &f);
printf ("Please enter the Principal:");
scanf ("%lf", &p);
printf ("Please enter the target age:");
scanf ("%d", &n);
i = POW ((f/p), 1.0/n)-1;
printf ("Annual rate of Return:%0.2lf\n", i);
}
void Getmutualfund ()
{
printf ("Please enter the amount of the annual fixed investment:");
scanf ("%lf", &p);
printf ("Please enter annual yield (percentage):");
scanf ("%lf", &i);
printf ("Please enter the number of years of investment:");
scanf ("%d", &n);
f = p* (1+i/100) * (Pow ((1+i/100), N)-1)/(I/100);
printf ("Fund investment proceeds:%0.2lf\n", f);
}
0320-Compounding Calculator code