#include <stdio.h>#include<math.h>voidList (); voidA (); voidB (); voidC (); voidD (); voidE ();voidF (); main () {intsel; List (); printf ("\ t Please select:"); while(SCANF ("%d", &sel)! =1|| sel<0|| Sel>6)//prevents the input of a character and the number entered is not an integer 0~6{printf ("\ t INPUT error!!! \n\n\t Please re-select:"); GetChar (); } Switch(SEL) {//Select the function of 0~6 Case 1: A (); Break; Case 2: B (); Break; Case 3: C (); Break; Case 4: D (); Break; Case 5: E (); Break; Case 6: F (); Break; Case 0://Exit Systemprintf"\ t Welcome to use again next time, thank you!\n"); Break; } } voidList ()//Catalog Table{printf ("\t|--------------------------------------|\n"); printf ("\t| Catalogue |\n"); printf ("\t|--------------------------------------|\n"); printf ("\t| |\n"); printf ("\t| 1. Compounding (one payment) |\n"); printf ("\t| 2. Compounding (multiple equal payments) |\n"); printf ("\t| 3. Simple Interest |\n"); printf ("\t| 4. Investment funds |\n"); printf ("\t| 5. Investment time |\n"); printf ("\t| 6. Interest rate |\n"); printf ("\t| 0. Exit |\n"); printf ("\t| |\n"); printf ("\t|--------------------------------------|\n"); } voidA ()//Compound Interest Calculation { intN//Time N DoubleP,I,SUM1;//Total amount P, interest rate I, Benli and sum1printf"\n\t* Please enter the total amount of the deposit:"); scanf ("%LF",&p); printf ("\t* Please enter the interest rate:"); scanf ("%LF",&i); printf ("\t* Please enter the time (year):"); scanf ("%d",&N); Sum1=p*pow ((1+i), n);//formula for compoundingprintf"\t** Benli and for:%.2lf\n", SUM1);//results of the output compounding calculation } voidB ()//multiple equal pay compounding calculation { intN; Doublep,i,sum2; printf ("\n\t* Please enter the total amount of the deposit:"); scanf ("%LF",&p); printf ("\t* Please enter the interest rate:"); scanf ("%LF",&i); printf ("\t* Please enter the time (year):"); scanf ("%d",&N); Sum2= (p* (POW (1+i), N)-1))/I;//formula for compoundingprintf"\t** Benli and for:%.2lf\n", sum2);//results of the output compounding calculation } voidC ()//Simple Interest Calculation { intN; Doublep,i,sum3; printf ("\n\t* Please enter the total amount of the deposit:"); scanf ("%LF",&p); printf ("\t* Please enter the interest rate:"); scanf ("%LF",&i); printf ("\t* Please enter the time (year):"); scanf ("%d",&N); SUM3=p* (1+i*N); printf ("\t** Benli and for:%.2lf\n", SUM3); } voidD ()//Investment Funds { intN; DoubleSum4,i,p;//P is the principal of the investmentprintf"\n\t* Please enter Benli and:"); scanf ("%LF",&sum4); printf ("\t* Please enter the interest rate:"); scanf ("%LF",&i); printf ("\t* Please enter the time (year):"); scanf ("%d",&N); P=SUM4/(1+i*N); printf ("the principal invested by \t** is:%.2lf\n", p); } voidE ()//Time to invest { DoubleN; Doublesum5,i,p; printf ("\n\t* Please enter the amount of input:"); scanf ("%LF",&p); printf ("\t* Please enter the interest rate:"); scanf ("%LF",&i); printf ("\t* Please enter Benli and:"); scanf ("%LF",&SUM5); N= (log (sum5/p))/(log (1+i)); printf ("The time \t** invested is:%.0lf\n", N); }voidF ()//Interest Rate{ intN; Doublesum6,i,p; printf ("\n\t* Please enter the amount of input:"); scanf ("%LF",&p); printf ("\t* Please enter the time (year):"); scanf ("%LF",&i); printf ("* Please enter Benli and:"); scanf ("%LF",&SUM6); I=pow (sum6/p,1/n)-1; printf ("\t** interest rate is:%.2lf\n", i);}
Compounding 3.0 Code