Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class E04everest {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int baseCamp = 5364;
- int mountEverest = 8848;
- int daysCounter = 1;
- String text = scanner.nextLine();
- if (text.equals("Yes")) {
- daysCounter++;
- }
- int currentPosition = baseCamp ;
- while (!text.equals("END")) {
- if (daysCounter > 5) {
- break;
- }
- currentPosition += Integer.parseInt(scanner.nextLine());
- if (currentPosition >= mountEverest) {
- System.out.printf("Goal reached for %d days!", daysCounter);
- break;
- }
- text = scanner.nextLine();
- if (text.equals("Yes")) {
- daysCounter++;
- }
- }
- if (currentPosition < mountEverest) {
- System.out.println("Failed!");
- System.out.println(currentPosition);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment