Browse Source

Implement interest calculator

remotes/origin/feature/loan-eligibility
fdlt3817 2 years ago
parent
commit
17903c5e0c
  1. 46
      src/interestCalculator.c
  2. 7
      src/interestCalculator.h

46
src/interestCalculator.c

@ -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();
}
*/

7
src/interestCalculator.h

@ -0,0 +1,7 @@
#ifndef INTERESTCALCULATOR_H_
#define INTERESTCALCULATOR_H_
#include <stdio.h>
void calculateInterest();
#endif
Loading…
Cancel
Save