Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Golf {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int record = Integer.parseInt(scanner.nextLine());
- int halls = Integer.parseInt(scanner.nextLine());
- int counter = 0;
- for (int i = 1; i <= halls; i++) {
- int strength = Integer.parseInt(scanner.nextLine());
- int memoryGoal = 0;
- while (!(memoryGoal >= strength)) {
- counter++;
- int goal = 0;
- String text = scanner.nextLine();
- for (int k = 0; k < text.length(); k++) {
- goal += text.charAt(k);
- }
- goal /= text.length();
- memoryGoal += goal;
- goal = 0;
- }
- System.out.printf("New hole reached! Hits so far: %d%n", counter);
- }
- if (counter < record) {
- System.out.printf("Yes, you won! Total hits: %d", counter);
- } else {
- System.out.printf("Better luck next time... Total hits: %d", counter);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment