Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class DartsTournament {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int startingPoints = Integer.parseInt(scan.nextLine());
- int counter = 1;
- String input = scan.nextLine();
- while (!input.equals("bullseye")) {
- int points = Integer.parseInt(scan.nextLine());
- if (input.equals("number section")) {
- startingPoints -= points;
- } else if (input.equals("double ring")) {
- startingPoints -= points * 2;
- } else if (input.equals("triple ring")) {
- startingPoints -= points * 3;
- }
- if (startingPoints == 0) {
- System.out.printf("Congratulations! You won the game in %d moves!%n", counter);
- break;
- }else if (startingPoints <0) {
- System.out.printf("Sorry, you lost. Score difference: %d.%n",Math.abs(startingPoints));
- break;
- }
- input = scan.nextLine();
- counter++;
- }
- if (input.equals("bullseye")) {
- System.out.printf("Congratulations! You won the game with a bullseye in %d moves!%n", counter);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement