Advertisement
IvaAnd

DartsTournament_05

Mar 24th, 2020
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class DartsTournament_05 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int countStartPoints = Integer.parseInt(scanner.nextLine());
  8.  
  9. int countStrikes = 0;
  10. boolean wonWithBullseye = false;
  11.  
  12. while (countStartPoints >0) {
  13. countStrikes++;
  14.  
  15. String mishena = scanner.nextLine();
  16.  
  17. if (mishena.equals("bullseye")) {
  18. wonWithBullseye = true;
  19. break;
  20. }
  21. int pointsMishena = Integer.parseInt(scanner.nextLine());
  22.  
  23.  
  24. if (mishena.equals("number section")) {
  25. countStartPoints = countStartPoints - pointsMishena;
  26. } else if (mishena.equals("double ring")) {
  27. pointsMishena = pointsMishena * 2;
  28. countStartPoints = countStartPoints - pointsMishena;
  29. } else if (mishena.equals("triple ring")) {
  30. pointsMishena = pointsMishena * 3;
  31. countStartPoints = countStartPoints - pointsMishena;
  32.  
  33. }if (countStartPoints < 0) {
  34. break;
  35. }
  36.  
  37. }
  38. if (countStartPoints == 0) {
  39. System.out.printf("Congratulations! You won the game in %d moves!", countStrikes);
  40. } else if (wonWithBullseye){
  41. System.out.printf("Congratulations! You won the game with a bullseye in %d moves!", countStrikes);
  42. }else {
  43. System.out.printf("Sorry, you lost. Score difference: %d.", Math.abs(countStartPoints));
  44. }
  45.  
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement