|
|
@ -23,22 +23,19 @@ void calculateYearlyInterest(){ |
|
|
|
float timeInYears; |
|
|
|
|
|
|
|
printf("Please enter the principal amount:"); |
|
|
|
scanf("%f",&principalAmount); |
|
|
|
if(principalAmount<=0){ |
|
|
|
if (scanf("%f", &principalAmount) != 1 || principalAmount <= 0) { |
|
|
|
troubleshoot(0); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
printf("\nPlease enter interest per year (percentage):"); |
|
|
|
scanf("%f",&interestPerYear); |
|
|
|
if(interestPerYear<=0){ |
|
|
|
troubleshoot(1); |
|
|
|
if (scanf("%f", &interestPerYear) != 1 || interestPerYear <= 0) { |
|
|
|
troubleshoot(0); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
printf("\nPlease enter interest time in years:"); |
|
|
|
scanf("%f",&timeInYears); |
|
|
|
if(timeInYears<=0){ |
|
|
|
if (scanf("%f", &timeInYears) != 1 || timeInYears <= 0) { |
|
|
|
troubleshoot(2); |
|
|
|
return; |
|
|
|
} |
|
|
@ -46,7 +43,7 @@ void calculateYearlyInterest(){ |
|
|
|
float interestDecimal=interestPerYear/100; |
|
|
|
|
|
|
|
float result= principalAmount*(1+(interestDecimal*timeInYears)); |
|
|
|
printf("\nAmount with the interest is %.2f.",result); |
|
|
|
printf("\nAmount with the interest is %.2f€.",result); |
|
|
|
} |
|
|
|
void calculateMonthlyInterest(){ |
|
|
|
float principalAmount; |
|
|
@ -54,22 +51,19 @@ void calculateMonthlyInterest(){ |
|
|
|
float timeInMonths; |
|
|
|
|
|
|
|
printf("Please enter the principal amount:"); |
|
|
|
scanf("%f",&principalAmount); |
|
|
|
if(principalAmount<=0){ |
|
|
|
if (scanf("%f", &principalAmount) != 1 || principalAmount <= 0) { |
|
|
|
troubleshoot(0); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
printf("\nPlease enter interest per month (percentage):"); |
|
|
|
scanf("%f",&interestPerMonth); |
|
|
|
if(interestPerMonth<=0){ |
|
|
|
troubleshoot(1); |
|
|
|
if (scanf("%f", &interestPerMonth) != 1 || interestPerMonth <= 0) { |
|
|
|
troubleshoot(0); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
printf("\nPlease enter interest time in months:"); |
|
|
|
scanf("%f",&timeInMonths); |
|
|
|
if(timeInMonths<=0){ |
|
|
|
if (scanf("%f", &timeInMonths) != 1 || timeInMonths <= 0) { |
|
|
|
troubleshoot(2); |
|
|
|
return; |
|
|
|
} |
|
|
@ -77,7 +71,7 @@ void calculateMonthlyInterest(){ |
|
|
|
float interestDecimal=interestPerMonth/100; |
|
|
|
|
|
|
|
float result= principalAmount*(1+(interestDecimal*timeInMonths)); |
|
|
|
printf("\nAmount with the interest is %.2f.",result); |
|
|
|
printf("\nAmount with the interest is %.2f€.",result); |
|
|
|
} |
|
|
|
|
|
|
|
void initiateCalculator(){ |
|
|
|