Advertisement
Guest User

Untitled

a guest
Mar 29th, 2019
617
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ExamPrep_HighJump {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int desiredHeight = Integer.parseInt(scanner.nextLine());
  8. int failTimes = 0;
  9. int totalJumpTimes = 0;
  10. boolean stop = false;
  11.  
  12. for (int actualHeight = desiredHeight - 30; actualHeight <= desiredHeight; actualHeight += 5) {
  13.  
  14. for (int i = 1; i <= 3; i++) {
  15.  
  16. int jumpHeight = Integer.parseInt(scanner.nextLine());
  17. if (jumpHeight > actualHeight) {
  18. totalJumpTimes++;
  19. failTimes = 0;
  20. break;
  21. } else {
  22. failTimes++;
  23. totalJumpTimes++;
  24. }
  25. }
  26.  
  27. if (failTimes == 3) {
  28. System.out.printf("Tihomir failed at %scm after %s jumps.", actualHeight, totalJumpTimes);
  29. stop = true;
  30.  
  31. }
  32. }
  33.  
  34. if (stop == false) {
  35. System.out.printf("Tihomir succeeded, he jumped over %scm after %s jumps.", desiredHeight, totalJumpTimes);
  36. }
  37. }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement