Advertisement
IvaAnd

DartsTournament_05

Mar 23rd, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 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.  
  11. while (countStartPoints >=100) {
  12. countStrikes++;
  13.  
  14. String mishena = scanner.nextLine();
  15. int pointsMishena = Integer.parseInt(scanner.nextLine());
  16.  
  17.  
  18. if (mishena.equals("number section")) {
  19. countStartPoints = countStartPoints - pointsMishena;
  20. } else if (mishena.equals("double ring")) {
  21. pointsMishena = pointsMishena * 2;
  22. countStartPoints = countStartPoints - pointsMishena;
  23. } else if (mishena.equals("triple ring")) {
  24. pointsMishena = pointsMishena * 3;
  25. countStartPoints = countStartPoints - pointsMishena;
  26. } else if (mishena.equals("bullseye")) {
  27. System.out.printf("Congratulations! You won the game with a bullseye in %d moves!", countStrikes);
  28. break;
  29. }
  30. if (countStartPoints <= 0) {
  31. break;
  32. }
  33.  
  34. }
  35. if (countStartPoints == 0) {
  36. System.out.printf("Congratulations! You won the game in %d moves!", countStrikes);
  37. } else if (countStartPoints < 0) {
  38. System.out.printf("Sorry, you lost. Score difference: %d.", Math.abs(countStartPoints));
  39. }
  40.  
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement