High Jump
Здравейте,
не мога да си намеря грешката
package Exam09And10March2019;
//ne e re6ena ima re6ka nqkade
import java.util.Scanner;
public class HighJump {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int desiredHeightInCentimeters = Integer.parseInt(scanner.nextLine());
int startingHeight = desiredHeightInCentimeters - 30;
int jumps = 0;
int unsuccsesful = 0;
int currentJump = 0;
int heightOfTheJump = Integer.parseInt(scanner.nextLine());
while(true) {
jumps++;
currentJump = startingHeight;
if(heightOfTheJump > currentJump) {
startingHeight += 5;
unsuccsesful = 0;
}else{
unsuccsesful++;
}
if(unsuccsesful == 3 || desiredHeightInCentimeters < heightOfTheJump) {
break;
}
heightOfTheJump = Integer.parseInt(scanner.nextLine());
}
if(unsuccsesful == 3) {
System.out.printf("Tihomir failed at %dcm after %d jumps.", heightOfTheJump, jumps);
}else {
System.out.printf("Tihomir succeeded, he jumped over %dcm after %d jumps.", currentJump, jumps);
}
}
}
Axiomatik благодаря много за решението, разбрах си грешката!