kalin729

Everest

Apr 17th, 2021 (edited)
754
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.08 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Everest {
  4.     public static void main(String[] args) {
  5.         Scanner s = new Scanner(System.in);
  6.  
  7.         String input = "";
  8.         int height = 5364;
  9.         int daysPassed = 1;
  10.         int km = 0;
  11.  
  12.         while (height<=8848 && daysPassed <= 5 && !input.equals("END")){
  13.             input = s.nextLine();
  14.             if (!input.equals("END")){
  15.                 if (input.equals("Yes")){
  16.                     daysPassed++;
  17.                 }
  18.                 input = s.nextLine();
  19.                 if (!input.equals("END")){
  20.                     km = Integer.parseInt(input);
  21.                     height += km;
  22.                 }
  23.  
  24.             }
  25.         }
  26.  
  27.         if (daysPassed<=5 && height>=8848){
  28.             System.out.println("Goal reached for " + daysPassed + " days!");
  29.         }else{
  30.             System.out.println("Failed!");
  31.             if (daysPassed>=5 & !input.equals("END")){
  32.                 System.out.println(height-km);
  33.             }else {
  34.                 System.out.println(height);
  35.             }
  36.         }
  37.     }
  38. }
Add Comment
Please, Sign In to add comment