Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package DecemberFirst;
- import java.util.Scanner;
- public class O4Everest {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int countHight = 5364;
- int countDays = 1;
- while (countHight < 8848) {
- String upOrStay = scanner.nextLine();
- if (upOrStay.equalsIgnoreCase("end")) {
- break;
- }
- if (upOrStay.equalsIgnoreCase("yes")) {
- countDays +=1;
- }
- if (countDays > 5) {
- break;
- }
- int climed = Integer.parseInt(scanner.nextLine());
- countHight += climed;
- }
- if (countDays <= 5 && countHight >= 8848) {
- System.out.printf("Goal reached for %d days!", countDays);
- } else {
- System.out.println("Failed!");
- System.out.println(countHight);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement