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 = 1;
		while(true) {
			String num;
			String goatName;
			int flag = 0;
			int goal = 0;
			num = sc.nextLine();
			if(num.equals("EOF")) {
				break;
			}
			int i = Integer.parseInt(num);
			for(int j = 0; j < i; j++) {
				goatName = sc.nextLine();
				if(goatName.equals("Pleasant goat")) 
					goal = goal + 5;
				else if(goatName.equals("Pretty goat"))
					goal = goal + 8;
				else if(goatName.equals("Athletic goat")) {
					goal = goal + 10;
					flag = 1;
				}
				else if(goatName.equals("Lazy goat"))
					goal = goal + 15;
				else if(goatName.equals("Slow goat"))
					goal = goal + 20;
			}
			if(i >=10 && flag == 1)
				goal = goal + 50;
			System.out.println("Case #" + count++ + ": " + goal);
		}
		
	}
}

Double click to view unformatted code.


Back to problem 9