Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class OP {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int desiredHeight = Integer.parseInt(scanner.nextLine());
- int heightMinus30cm = desiredHeight - 30;
- int unsuccessfulTry = 0;
- int jumps = 0;
- while (true){
- for (int i = 1; i <= 3 ; i++) {
- int jump = Integer.parseInt(scanner.nextLine());
- jumps++;
- if (jump > heightMinus30cm){
- heightMinus30cm += 5;
- unsuccessfulTry = 0;
- i = 1;
- if (jump > desiredHeight){
- System.out.printf("Tihomir succeeded, he jumped over %dcm after %d jumps.", desiredHeight, jumps);
- return;
- }
- }else {
- unsuccessfulTry++;
- if (unsuccessfulTry == 3){
- System.out.printf("Tihomir failed at %dcm after %d jumps.", jump, jumps);
- return;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement