View Code of Problem 9


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = 0;
        while (sc.hasNext()){
            String s1 = sc.nextLine();
            if(s1.equals("EOF"))
                break;
            int sum =0;
            boolean flag = false;
            int n = Integer.parseInt(s1);
            for (int i = 0; i < n; i++) {
                String str = sc.nextLine();
                if(str.equals("Pleasant goat"))
                    sum += 5;
                if(str.equals("Pretty goat"))
                    sum +=8;
                if(str.equals("Athletic goat"))
                    sum += 10;
                flag=true;
                if(str.equals("Lazy goat"))
                    sum += 15;
                if(str.equals("Slow goat"))
                    sum +=20;
            }
            if(n>=10&&flag==true)
                sum += 50;
            count++;
            System.out.println("Case #"+count+": "+sum);
        }

    }
}

Double click to view unformatted code.


Back to problem 9