aneliabogeva

Walking

Nov 17th, 2020
444
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×