import java.util.Scanner; public class Q9 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int count = 1; while(true) { String s; String goatName; int flag = 0; int goal = 0; s = sc.nextLine(); if(s.equals("EOF")) { break; } int i = Integer.parseInt(s); 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); } } } /* Main.java:3: error: class Q9 is public, should be declared in a file named Q9.java public class Q9 { ^ 1 error */ |
Double click to view unformatted code.