galinyotsev123

ProgBasicsExam1and2December2018-E04everest

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