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