Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Walking {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String steps = scanner.nextLine();
- int stepsSum=0;
- while(!steps.equals("Going home")){
- int todaySteps = Integer.parseInt(steps);
- stepsSum +=todaySteps;
- if (stepsSum >=10000){
- break;
- }
- steps = scanner.nextLine();
- }
- if (steps.equals("Going home")){
- int stepsToHome = Integer.parseInt(scanner.nextLine());
- stepsSum +=stepsToHome;
- }
- if (stepsSum >= 10000){
- int moreSteps = stepsSum - 10000;
- System.out.println("Goal reached! Good job!");
- System.out.printf("%d steps over the goal!",moreSteps);
- }else{
- System.out.printf("%d more steps to reach goal.",10000-stepsSum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement