Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ProgammingBasics;
- import java.util.Scanner;
- public class Steps {
- public static void main(String[] args){
- Scanner scanner = new Scanner(System.in);
- int walkingSteps=0;
- while(true){
- String Steps = scanner.nextLine();
- if(Steps.equalsIgnoreCase("Going home")){
- System.out.printf("%d more steps to reach goal.",10000-walkingSteps);
- break;
- }
- walkingSteps=Integer.parseInt(Steps);
- int sumSteps=10000-walkingSteps;
- if(sumSteps<=0){
- System.out.println("Goal reached! Good job!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment