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