Browse Source

Improve interest calculator to check for invalid inputs

remotes/origin/feature/loan-eligibility
fdlt3817 2 years ago
parent
commit
714b7cbc6a
  1. 9
      src/interestCalculator.c

9
src/interestCalculator.c

@ -8,12 +8,21 @@ float timeInYears;
printf("Please enter the principal amount:");
scanf("%f",&principalAmount);
if(principalAmount<=0){
return;
}
printf("\nPlease enter interest per year (percentage):");
scanf("%f",&interestPerYear);
if(interestPerYear<=0){
return;
}
printf("\nPlease enter interest time in years:");
scanf("%f",&timeInYears);
if(timeInYears<=0){
return;
}
float interestDecimal=interestPerYear/100;

Loading…
Cancel
Save