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