Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int neededSteps = 10000;
- String input;
- while (neededSteps > 0) {
- input = scanner.nextLine();
- if (input.equals("Going home")) {
- neededSteps -= Integer.parseInt(scanner.nextLine());
- break;
- }
- neededSteps -= Integer.parseInt(input);
- }
- if (neededSteps <= 0) {
- System.out.println("Goal reached! Good job!");
- } else {
- System.out.println(neededSteps + " more steps to reach goal.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement