BUPT-homework/semester1/pset2/5-shopping.c

24 lines
406 B
C

#include <stdio.h>
int main(void) {
// add up money
int total = 0, single;
for (int i = 0; i < 4; i++) {
scanf("%i", &single);
total += single;
}
// evaluate results
if (total >= 40) {
printf("%i", total);
} else if (total >= 30) {
printf("%i", total + 5);
} else if (total >= 20) {
printf("%i", total + 8);
} else {
printf("%i", total + 10);
}
return 0;
}