Advertisement
dagrizzly

Untitled

Jul 23rd, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class HighJump2 {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.  
  10.         int goalBarHigth =  Integer.parseInt(scanner.nextLine());
  11.         int currentBarHeigth = goalBarHigth - 30;
  12.         int countFails = 0;
  13.  
  14.         for (int i=1; ;i++){
  15.             int currentAtempt = Integer.parseInt(scanner.nextLine());
  16.             if (currentAtempt > goalBarHigth){
  17.                 System.out.printf("Tihomir succeeded, he jumped over %dcm after %d jumps.", goalBarHigth, i);
  18.                 break;
  19.             } else if (currentAtempt > currentBarHeigth){
  20.                 currentBarHeigth += 5;
  21.                 countFails = 0;
  22.             } else {
  23.                 countFails++;
  24.             }
  25.             if (countFails == 3){
  26.                 System.out.printf("Tihomir failed at %dcm after %d jumps.", currentBarHeigth, i);
  27.                 break;
  28.             }
  29.  
  30.         }
  31.  
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement