Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String name = scanner.nextLine(),
- zone;
- int dots, yesCount = 0, noCount = 0, total = 301;
- while (total > 0 && !(zone = scanner.nextLine()).equals("Retire")) {
- dots = Integer.parseInt(scanner.nextLine());
- if (zone.equals("Double")) {
- dots *= 2;
- } else if (zone.equals("Triple")) {
- dots *= 3;
- }
- if (total < dots) {
- noCount++;
- } else {
- total -= dots;
- yesCount++;
- }
- }
- if (total == 0) {
- System.out.println(name + " won the leg with " + yesCount + " shots.");
- } else {
- System.out.println(name + " retired after " + noCount + " unsuccessful shots.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement