Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Everest {
- public static void main(String[] args) {
- Scanner s = new Scanner(System.in);
- String input = "";
- int height = 5364;
- int daysPassed = 1;
- int km = 0;
- while (height<=8848 && daysPassed <= 5 && !input.equals("END")){
- input = s.nextLine();
- if (!input.equals("END")){
- if (input.equals("Yes")){
- daysPassed++;
- }
- input = s.nextLine();
- if (!input.equals("END")){
- km = Integer.parseInt(input);
- height += km;
- }
- }
- }
- if (daysPassed<=5 && height>=8848){
- System.out.println("Goal reached for " + daysPassed + " days!");
- }else{
- System.out.println("Failed!");
- if (daysPassed>=5 & !input.equals("END")){
- System.out.println(height-km);
- }else {
- System.out.println(height);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment