View Code of Problem 9

#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, cal = 1;
    while (scanf("%d", &n) != EOF) {
        int sum = 0, flag = 0;
        string s;
        getchar();
        for (int i = 0; i < n; i++) {
            getline(cin, s);
            if (s == "Pleasant goat") sum += 5;
            else if (s == "Pretty goat") sum += 8;
            else if (s == "Athletic goat") {                
                sum += 10;
                flag = 1;
            }
            else if (s == "Lazy goat") sum += 15;
            else if (s == "Slow goat") sum += 20;
        }
        if (flag == 1 && n >= 10) sum += 50;
        printf("Case #%d: %d\n", cal++, sum);
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 9