Advertisement
Sim0o0na

Everest

Jul 3rd, 2019
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Everest {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. String input = scanner.nextLine();
  8. int countRest = 1;
  9. int countMeters = 5364;
  10. int everest = 8848;
  11.  
  12. while (!input.equals("END")) {
  13. int meters = Integer.parseInt(scanner.nextLine());
  14. if (input.equals("Yes")) {
  15. countRest += 1;
  16. if (countRest > 5) break;
  17. }
  18. countMeters += meters;
  19.  
  20. if (countMeters >= everest) {
  21. break;
  22. }
  23.  
  24. input = scanner.nextLine();
  25.  
  26. }
  27. if (countMeters >= everest) {
  28. System.out.printf("Goal reached for %d days!", countRest);
  29. }
  30.  
  31. if (countMeters < everest) {
  32. System.out.printf("Failed!%n%d", countMeters);
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement