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