SHARE
TWEET

Untitled

a guest Apr 19th, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package Exam12January2019;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Everest {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         String nights = scanner.nextLine();
  9.  
  10.         int counter = 1;
  11.         int startPoint = 5364;
  12.         int endPoint = 8848;
  13.  
  14.  
  15.         if (nights.equals("END")) {
  16.             return;
  17.         }
  18.         while (!nights.equals("END")) {
  19.             int metres = Integer.parseInt(scanner.nextLine());
  20.             if (nights.equals("Yes")) {
  21.                 counter++;
  22.                 if (counter > 5) {
  23.                     break;
  24.                 } else {
  25.                     startPoint += metres;
  26.                     if (startPoint >= endPoint) {
  27.                         break;
  28.                     }
  29.                 }
  30.             } else if (nights.equals("No")) {
  31.                 startPoint += metres;
  32.                 if (startPoint >= endPoint) {
  33.                     break;
  34.                 }
  35.             }
  36.             nights = scanner.nextLine();
  37.         }
  38.         if (startPoint >= endPoint) {
  39.             System.out.printf("Goal reached for %d days!", counter);
  40.         } else {
  41.             System.out.println("Failed!");
  42.             System.out.printf("%d",startPoint);
  43.         }
  44.     }
  45. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top