Advertisement
aneliabogeva

Walking

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