Advertisement
Spocoman

Everest

Sep 5th, 2024
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int reachedHeight = 5364, days = 1, daylyHeight;
  7.         String sleep;
  8.  
  9.         while (reachedHeight < 8848 && !(sleep = scanner.nextLine()).equals("END")) {
  10.             if (sleep.equals("Yes")) {
  11.                 if (++days == 6) {
  12.                     break;
  13.                 }
  14.             }
  15.             daylyHeight = Integer.parseInt(scanner.nextLine());
  16.             reachedHeight += daylyHeight;
  17.         }
  18.  
  19.         if (reachedHeight >= 8848) {
  20.             System.out.println("Goal reached for " + days + " days!");
  21.         } else {
  22.             System.out.println("Failed!\n" + reachedHeight);
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement