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