Advertisement
petar088

Untitled

Oct 20th, 2019
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. import java.lang.reflect.Array;
  2. import java.util.*;
  3.  
  4. public class proba {
  5. public static void main(String[] args) {
  6.  
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9.  
  10. int totalSteps = 0;
  11.  
  12. while (totalSteps < 10000){
  13. String string = scanner.nextLine();
  14. if ("Going home". equals(string)) {
  15. int stepsToHome = Integer.parseInt(scanner.nextLine());
  16. totalSteps += stepsToHome;
  17. break;
  18. }
  19. int steps = Integer.parseInt(string);
  20. totalSteps += steps;
  21. }
  22. if (totalSteps >= 10000){
  23. System.out.printf("Goal reached! good job!");
  24. }else {
  25. int difference = 10000 - totalSteps;
  26. System.out.printf("%d more steps to reach goal.", difference);
  27. }
  28.  
  29.  
  30.  
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement