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