Advertisement
Guest User

Walking

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