Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int jumpTarget = Integer.parseInt(scanner.nextLine()),
- jump, startJump = jumpTarget - 30, counter = 0, fall = 0;
- while (fall != 3 && startJump <= jumpTarget) {
- jump = Integer.parseInt(scanner.nextLine());
- if (jump > startJump) {
- startJump += 5;
- fall = 0;
- } else {
- fall++;
- }
- counter++;
- }
- if (startJump <= jumpTarget) {
- System.out.println("Tihomir failed at " + startJump + "cm after " + counter + " jumps.");
- } else {
- System.out.println("Tihomir succeeded, he jumped over " + jumpTarget + "cm after " + counter + " jumps.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement