SophiYo

Ex.04 Everest

Dec 5th, 2018
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 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.             if (countDays > 4) {
  18.                 break;
  19.             }
  20.  
  21.             if (upOrStay.equalsIgnoreCase("yes")) {
  22.                 countDays +=1;
  23.             }
  24.  
  25.             int climed = Integer.parseInt(scanner.nextLine());
  26.             countHight += climed;
  27.         }
  28.  
  29.         if (countDays <= 5 && countHight >= 8848) {
  30.             System.out.printf("Goal reached for %d days!", countDays);
  31.         } else {
  32.             System.out.println("Failed!");
  33.             System.out.println(countHight);
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment