Advertisement
Guest User

Everest

a guest
Jan 24th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. package examPBDecember2018;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Task4_Everest {
  6. public static void main(String[] args) {
  7. @SuppressWarnings("resource")
  8.  
  9. Scanner sc = new Scanner(System.in);
  10. int start = 5364;
  11. int countDays = 1;
  12.  
  13. while (start < 8848) {
  14. String sleep = sc.nextLine();
  15.  
  16. if (sleep.equals("END")) {
  17. break;
  18. }
  19.  
  20. if (sleep.equals("Yes")) {
  21. countDays++;
  22. }
  23.  
  24. if (countDays > 5) {
  25. break;
  26. }
  27.  
  28. int meters = Integer.parseInt(sc.nextLine());
  29. start += meters;
  30. }
  31.  
  32. if (countDays <= 5 && start >= 8848) {
  33. System.out.printf("Goal reached for %d days!", countDays);
  34. } else {
  35. System.out.printf("Failed!%n%d", start);
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement