|
@ -20,6 +20,24 @@ void troubleshoot(int errorCode){ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void askForSavingGoal(float principalAmount, float accInterestPerYear){ |
|
|
|
|
|
char c; |
|
|
|
|
|
float goal; |
|
|
|
|
|
float timeForGoal; |
|
|
|
|
|
printf("\nWould you like to set a saving goal?"); |
|
|
|
|
|
scanf(" %c",&c); |
|
|
|
|
|
|
|
|
|
|
|
if(c=='y'||c=='Y'){ |
|
|
|
|
|
printf("\nPlease enter your goal amount in €:"); |
|
|
|
|
|
scanf("%f",&goal); |
|
|
|
|
|
timeForGoal=(goal-principalAmount)/accInterestPerYear; |
|
|
|
|
|
printf("In %.1f years you will reach your goal of %f.\n", timeForGoal, goal); |
|
|
|
|
|
}else{ |
|
|
|
|
|
//error |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
float initiateInterest(float principalAmount, float interest, float time){ |
|
|
float initiateInterest(float principalAmount, float interest, float time){ |
|
|
return principalAmount*(1+(interest*time)); |
|
|
return principalAmount*(1+(interest*time)); |
|
|
} |
|
|
} |
|
@ -67,6 +85,7 @@ void calculateYearlyInterest(){ |
|
|
|
|
|
|
|
|
float result= initiateInterest(principalAmount,interestDecimal,timeInYears); |
|
|
float result= initiateInterest(principalAmount,interestDecimal,timeInYears); |
|
|
printf("\nAmount with the interest is %.2f€.",result); |
|
|
printf("\nAmount with the interest is %.2f€.",result); |
|
|
|
|
|
askForSavingGoal(principalAmount,principalAmount*interestDecimal); |
|
|
} |
|
|
} |
|
|
void calculateMonthlyInterest(){ |
|
|
void calculateMonthlyInterest(){ |
|
|
float principalAmount; |
|
|
float principalAmount; |
|
@ -123,8 +142,8 @@ void initiateCalculator(){ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// int main(){ |
|
|
|
|
|
|
|
|
int main(){ |
|
|
|
|
|
|
|
|
// initiateCalculator(); |
|
|
|
|
|
|
|
|
initiateCalculator(); |
|
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
} |