|
|
@ -14,6 +14,9 @@ void troubleshoot(int errorCode){ |
|
|
|
case 2: |
|
|
|
printf("Duration not valid. Make sure it is a valid number over the value of zero."); |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
printf("Invalid option. Aborting."); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -25,6 +28,7 @@ void calculateYearlyInterest(){ |
|
|
|
float principalAmount; |
|
|
|
float interestPerYear; |
|
|
|
float timeInYears; |
|
|
|
int choice; |
|
|
|
|
|
|
|
printf("Please enter the principal amount:"); |
|
|
|
if (scanf("%f", &principalAmount) != 1 || principalAmount <= 0) { |
|
|
@ -37,12 +41,27 @@ void calculateYearlyInterest(){ |
|
|
|
troubleshoot(0); |
|
|
|
return; |
|
|
|
} |
|
|
|
printf("\nWould you like to enter the time in [1]months or in [2]years?\n"); |
|
|
|
scanf("%d",&choice); |
|
|
|
if(choice==1){ |
|
|
|
printf("\nPlease enter interest time in months:"); |
|
|
|
if (scanf("%f", &timeInYears) != 1 || timeInYears <= 0) { |
|
|
|
troubleshoot(2); |
|
|
|
return; |
|
|
|
} |
|
|
|
timeInYears=timeInYears/12; |
|
|
|
|
|
|
|
}else if(choice==2){ |
|
|
|
printf("\nPlease enter interest time in years:"); |
|
|
|
if (scanf("%f", &timeInYears) != 1 || timeInYears <= 0) { |
|
|
|
troubleshoot(2); |
|
|
|
return; |
|
|
|
} |
|
|
|
}else{ |
|
|
|
troubleshoot(2); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float interestDecimal=interestPerYear/100; |
|
|
|
|
|
|
|