|
@ -0,0 +1,46 @@ |
|
|
|
|
|
#include "interestCalculator.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void calculateInterest(){ |
|
|
|
|
|
float principalAmount; |
|
|
|
|
|
float interestPerYear; |
|
|
|
|
|
float timeInYears; |
|
|
|
|
|
|
|
|
|
|
|
printf("Please enter the principal amount:"); |
|
|
|
|
|
scanf("%f",&principalAmount); |
|
|
|
|
|
|
|
|
|
|
|
printf("\nPlease enter interest per year (percentage):"); |
|
|
|
|
|
scanf("%f",&interestPerYear); |
|
|
|
|
|
|
|
|
|
|
|
printf("\nPlease enter interest time in years:"); |
|
|
|
|
|
scanf("%f",&timeInYears); |
|
|
|
|
|
|
|
|
|
|
|
float interestDecimal=interestPerYear/100; |
|
|
|
|
|
|
|
|
|
|
|
float result= principalAmount*(1+(interestDecimal*timeInYears)); |
|
|
|
|
|
printf("\nAmount with the interest is %f.",result); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void initiateCalculator(){ |
|
|
|
|
|
|
|
|
|
|
|
int input; |
|
|
|
|
|
printf("Welcome to the interest calculator. Please select an option:\n[1]Calculate yearly interest\n"); |
|
|
|
|
|
scanf("%d", &input); |
|
|
|
|
|
|
|
|
|
|
|
switch(input){ |
|
|
|
|
|
case 1: |
|
|
|
|
|
calculateInterest(); |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
int main(){ |
|
|
|
|
|
|
|
|
|
|
|
initiateCalculator(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
*/ |