Advertisement
Lyubohd

Problem_Everest

Dec 15th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. package DecemberFirst;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class O4Everest {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         int countHight = 5364;
  9.         int countDays = 1;
  10.  
  11.         while (countHight < 8848) {
  12.             String upOrStay = scanner.nextLine();
  13.  
  14.             if (upOrStay.equalsIgnoreCase("end")) {
  15.                 break;
  16.             }
  17.            
  18.  
  19.             if (upOrStay.equalsIgnoreCase("yes")) {
  20.                 countDays +=1;
  21.             }
  22.          
  23.             if (countDays > 5) {
  24.                 break;
  25.             }
  26.  
  27.             int climed = Integer.parseInt(scanner.nextLine());
  28.             countHight += climed;
  29.         }
  30.  
  31.         if (countDays <= 5 && countHight >= 8848) {
  32.             System.out.printf("Goal reached for %d days!", countDays);
  33.         } else {
  34.             System.out.println("Failed!");
  35.             System.out.println(countHight);
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement