getpay.c (927B)
1 /* Exercise 6.10 */ 2 3 #include <stdio.h> 4 5 #define BASE 200 /* base pay */ 6 #define XC 9 /* percentage */ 7 #define I_VAL 10 /* intervals */ 8 9 int main() 10 { 11 int interval[I_VAL] = { 0 }; /* interval[0] == current total */ 12 13 printf("Enter your gross total (%d to end): ", EOF); 14 scanf("%d", &interval[0]); 15 16 while(interval[0] != EOF) { 17 interval[0] = BASE + interval[0] * XC / 100; 18 printf("\nYour pay is $%d\n\n", interval[0]); 19 20 if(interval[0] >= 1000) 21 ++interval[1]; 22 else 23 ++interval[interval[0] / 100 % 10]; 24 25 printf("Enter your gross total (%d to end): ", EOF); 26 scanf("%d", &interval[0]); 27 } 28 29 printf("Results:\n"); 30 31 for(interval[0] = 2; interval[0] < I_VAL; interval[0]++) { 32 printf("$%d to $%d: %d\n", 33 interval[0] * 100, interval[0] * 100 + 99, interval[interval[0]]); 34 } 35 printf("More of $%d: %d\n", 1000, interval[1]); 36 37 return 0; 38 } /* E0F main */ 39