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);
- int startPoints = Integer.parseInt(scanner.nextLine()),
- points, moves = 0;
- String command;
- while (startPoints > 0) {
- moves ++;
- command = scanner.nextLine();
- if (command.equals("bullseye")) {
- break;
- }
- points = Integer.parseInt(scanner.nextLine());
- if (command.equals("double ring")) {
- points *= 2;
- } else if (command.equals("triple ring")) {
- points *= 3;
- }
- startPoints -= points;
- }
- if (startPoints == 0) {
- System.out.println("Congratulations! You won the game in " + moves + " moves!");
- } else if (startPoints < 0) {
- System.out.println("Sorry, you lost. Score difference: " + Math.abs(startPoints) + ".");
- } else {
- System.out.println("Congratulations! You won the game with a bullseye in " + moves + " moves!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement