0320-Compounding Calculator code

Source: Internet
Author: User

#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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.