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 goal = 10000;
- int stepsCounter = 0;
- while (stepsCounter <= goal) {
- String input = scanner.nextLine();
- if (input.equals("Going home")) {
- break;
- }
- int steps = Integer.parseInt(input);
- stepsCounter += steps;
- }
- if (input.equals("Going home")) {
- int moreStepsNeeded = goal - stepsCounter;
- System.out.printf("%d more steps to reach goal.", moreStepsNeeded);
- } else {
- System.out.println("Goal reached! Good job!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement