Advertisement
Lyubohd

Steps

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