Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package examPBDecember2018;
- import java.util.Scanner;
- public class Task4_Everest {
- public static void main(String[] args) {
- @SuppressWarnings("resource")
- Scanner sc = new Scanner(System.in);
- int start = 5364;
- int countDays = 1;
- while (start < 8848) {
- String sleep = sc.nextLine();
- if (sleep.equals("END")) {
- break;
- }
- if (sleep.equals("Yes")) {
- countDays++;
- }
- if (countDays > 5) {
- break;
- }
- int meters = Integer.parseInt(sc.nextLine());
- start += meters;
- }
- if (countDays <= 5 && start >= 8848) {
- System.out.printf("Goal reached for %d days!", countDays);
- } else {
- System.out.printf("Failed!%n%d", start);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement