Advertisement
Krassi_Daskalova

Walking

Mar 14th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Steps {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. int totalSteps = 0;
  7.  
  8. while (totalSteps < 10000) {
  9. String input = scanner.nextLine();
  10.  
  11. if (input.equals("Going home")) {
  12. int stepsToHome = Integer.parseInt(scanner.nextLine());
  13. totalSteps = totalSteps + stepsToHome;
  14. break;
  15. }
  16. int steps = Integer.parseInt(input);
  17. totalSteps = totalSteps + steps;
  18. }
  19. if (totalSteps >= 10000) {
  20. System.out.println("Goal reached! Good job!");
  21. } else {
  22. System.out.printf("%d more steps to reach goal.", 10000 - totalSteps);
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement