|
@ -27,25 +27,27 @@ void askForSavingGoal(float principalAmount, float accInterestPerYear){ |
|
|
char c; |
|
|
char c; |
|
|
float goal; |
|
|
float goal; |
|
|
float timeForGoal; |
|
|
float timeForGoal; |
|
|
printf("\nWould you like to set a saving goal? [y] yes [any] no"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("\nWould you like to set a saving goal? [y/n]: "); |
|
|
scanf(" %c", &c); |
|
|
scanf(" %c", &c); |
|
|
|
|
|
|
|
|
if(c=='y'||c=='Y'){ |
|
|
|
|
|
|
|
|
if (c != 'y' && c != 'Y') { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
printf("\nPlease enter your goal amount in €: "); |
|
|
printf("\nPlease enter your goal amount in €: "); |
|
|
scanf("%f", &goal); |
|
|
scanf("%f", &goal); |
|
|
if(goal>=principalAmount){ |
|
|
|
|
|
timeForGoal=(goal-principalAmount)/accInterestPerYear; |
|
|
|
|
|
printf("\nIn %.1f years you will reach your goal of %f.\n", timeForGoal, goal); |
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (goal < principalAmount) { |
|
|
troubleshoot(4); |
|
|
troubleshoot(4); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
}else{ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
timeForGoal = (goal - principalAmount) / accInterestPerYear; |
|
|
|
|
|
printf("\nIn %.1f years you will reach your goal of %.2f.\n", timeForGoal, goal); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)); |
|
|
} |
|
|
} |
|
|