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