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