I am having trouble figuring out a way to "cut off" the program from putting more than 5 $1,000 scholarships and 10 $500 scholarships. How would I cut it off after 5 and 8 from what I already have? My code is below the problem
One division of Programmers for a Better Tomorrow is their Scholarship Endowment Fund. They provide yearly scholarships to students who need a hand in amounts of 1000, 500, and 250 dollars. The money for these scholarships comes from interest made on previous donations and investments.
You will create a program to compute the yearly interest in the Fund and determine how many $1000, $500, and $250 scholarships can be awarded. For example, if the Fund had 500,000 dollars in it on September 30th 2016 and the yearly interest rate was 3 percent then the Fund will have 515,000 dollars in it at the end of this September. This gives them $15,000 to disburse as scholarship money.
If possible, the Fund prefers to award 5 $1000 scholarships, 10 $500 scholarships, and as many $250 as they have money left for. With $15,000 the Fund can award 5 $1000 scholarships, 10 $500 scholarships, and 20 $250 scholarships. Your program should print this information for the user.
If that is not possible, the Fund will award as many $1000 and $500 scholarships as they can.
For example, if they had $4,750 they would award 4 $1000 scholarships, 1 $500 scholarship, and 1 $250 scholarship.
Input Specification
- The amount of money in the fund, n, as of one year ago where n is greater than or equal to 0. (n may include decimal places)
- The yearly percent rate, p, as an integer where p is greater than zero.
Output Specification
Output the result using the format below:
X $1000 scholarships will be awarded.
Y $500 scholarships will be awarded.
Z $250 scholarships will be awarded
My code so far:
#include <stdio.h>
#include <math.h>
//main function
int main() {
int ten, five, twofive, leftovers_ten, leftovers_five, scholarship_money;
float fund, interest;
printf("How much was in the fund last year?\n");
scanf("%f", &fund);
printf("What is the yearly percentage rate?\n");
scanf("%f", &interest);
scholarship_money = fund * (interest / 100);
{
if(ten < 5) {
ten = scholarship_money / 1000;
printf("%d $1000 scholarships will be awarded.\n", ten);
}
else {
ten = 5;
printf("5 $1000 scholarships will be awarded.\n");
}
}
leftovers_ten = scholarship_money - (ten * 1000);
{
if(five < 10) {
five = leftovers_ten / 500;
printf("%d $500 scholarships will be awarded.\n", five);
}
else {
five = 10;
printf("10 $500 scholarships will be awarded.\n");
}
}
leftovers_five = leftovers_ten - (five * 500);
twofive = leftovers_five / 250;
printf("%d $250 scholarships will be awarded.\n", twofive);
return 0;
}