Advertisement
kristiyanasimeonova

Untitled

Oct 10th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 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. String input = scanner.nextLine();
  7. int totalSteps = Integer.parseInt(input);
  8.  
  9.  
  10. while (totalSteps < 10000) {
  11. input = scanner.nextLine();
  12. if (input.equals("Going home")) {
  13. totalSteps += Integer.parseInt(scanner.nextLine());
  14. break;
  15. }else {
  16. totalSteps += Integer.parseInt(input);
  17. }
  18. }
  19. if (totalSteps >= 10000) {
  20. System.out.println("Goal reached! Good job!");
  21. } else {
  22. System.out.printf("%d more steps to reach goal.", (10000 - totalSteps));
  23. }
  24.  
  25. }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement