Advertisement
MoPhreak

Untitled

Oct 12th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Walking {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. int steps = Integer.parseInt(scanner.nextLine());
  7. while (steps < 10000) {
  8. String end = scanner.nextLine().toLowerCase();
  9. if (end.equals("going home")) {
  10. steps += Integer.parseInt(scanner.nextLine());
  11. break;
  12. } else {
  13. steps += Integer.parseInt(end);
  14. }
  15. }
  16. if (steps >= 10000) {
  17. System.out.println("Goal reached! Good job!");
  18. } else {
  19. System.out.println((10000 - steps) + " more steps to reach goal.");
  20. }
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement