Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Demo {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int steps = 0;
- while (steps <= 10000) {
- String input = scan.nextLine();
- if ("GoiNg hOme".equalsIgnoreCase(input)) {
- int stepsToHome = Integer.parseInt(scan.nextLine());
- steps += stepsToHome;
- break;
- }
- int stepPerDay = Integer.parseInt(input);
- steps += stepPerDay; // steps = steps + stepsPerDay
- }
- if (steps >= 10000) {
- System.out.println("Goal reached! Good job!");
- } else {
- int stepsToReach = 10000 - steps;
- System.out.printf("%d more steps to reach goal.", stepsToReach);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement