1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
//main function
int main() {
const int BEST_SCHOLARSHIP_COST = 1000;
const int MEDIUM_SCHOLARSHIP_COST = 500;
const int WORST_SCHOLARSHIP_COST = 250;
int funds;
int bestScholarshipAwarded = 0;
int mediumScholarshipAwarded = 0;
int worstScholarshipAwarded = 0;
int remainder = 0;
int remainingmedium = 0;
int amount, interest, remainingbest;
printf("How much was in the fund last year?\n");
scanf("%d", &amount);
printf("What is the yearly percentage rate?\n");
scanf("%d", &interest);
//formula
funds = (amount * interest/100);
// Checking the if funds are more than or equal to BEST
if (funds >= BEST_SCHOLARSHIP_COST) {
bestScholarshipAwarded = funds / BEST_SCHOLARSHIP_COST;
if(bestScholarshipAwarded > 5){
remainder = bestScholarshipAwarded - 5;
bestScholarshipAwarded = 5;
remainingbest = BEST_SCHOLARSHIP_COST * remainder;
printf("%d $1000 scholarships will be awarded.\n", bestScholarshipAwarded);
}else{
remainder = bestScholarshipAwarded % 1;
bestScholarshipAwarded -= remainder;
remainingbest = BEST_SCHOLARSHIP_COST * remainder;
printf("%d $1000 scholarships will be awarded.\n", bestScholarshipAwarded);
}
// taking the remainder of the Math above and checking to see if it is
// more or equal to Medium and the else is if it is more or equal to Worst
if(remainingbest >= MEDIUM_SCHOLARSHIP_COST){
mediumScholarshipAwarded = remainingbest / MEDIUM_SCHOLARSHIP_COST;
if(mediumScholarshipAwarded > 10){
remainder = mediumScholarshipAwarded - 10;
mediumScholarshipAwarded = 10;
remainingmedium = MEDIUM_SCHOLARSHIP_COST * remainder;
printf("%d $500 scholarships will be awarded.\n", mediumScholarshipAwarded);
}else{
remainder = mediumScholarshipAwarded % 1;
mediumScholarshipAwarded -= remainder;
remainingmedium = MEDIUM_SCHOLARSHIP_COST * remainder;
printf("%d $500 scholarships will be awarded.\n", mediumScholarshipAwarded);
}
worstScholarshipAwarded = remainingmedium / WORST_SCHOLARSHIP_COST;
printf("%d $250 scholarships will be awarded.\n", worstScholarshipAwarded);
}else{
worstScholarshipAwarded = remainingmedium / WORST_SCHOLARSHIP_COST;
printf("%d $250 scholarships will be awarded.\n", worstScholarshipAwarded);
}
// Checking if funds are more than or equal to MEDIUM but obivously less then BEST
}else if(funds >= MEDIUM_SCHOLARSHIP_COST){
mediumScholarshipAwarded = funds / MEDIUM_SCHOLARSHIP_COST;
if(mediumScholarshipAwarded > 5){
mediumScholarshipAwarded -= 5;
remainder = mediumScholarshipAwarded % 2;
mediumScholarshipAwarded -= remainder;
remainingmedium = MEDIUM_SCHOLARSHIP_COST * remainder;
printf("%d $500 scholarships will be awarded.\n", mediumScholarshipAwarded);
}else{
remainder = mediumScholarshipAwarded % 1;
mediumScholarshipAwarded -= remainder;
remainingmedium = MEDIUM_SCHOLARSHIP_COST * remainder;
printf("%d $500 scholarships will be awarded.\n", mediumScholarshipAwarded);
}
// taking the remainder of the Math above and checking to see if it is
// more or equal to Worst
if (remainingmedium >= WORST_SCHOLARSHIP_COST) {
worstScholarshipAwarded = remainingmedium / WORST_SCHOLARSHIP_COST;
printf("%d $250 scholarships will be awarded.\n", worstScholarshipAwarded);
}
//Lastly seeing if it is more or equal to WORST
}else{
worstScholarshipAwarded = funds / WORST_SCHOLARSHIP_COST;
printf("%d $250 scholarships will be awarded.\n", worstScholarshipAwarded);
}
return 0;
}
|