Advertisement
desislavg

Untitled

May 19th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Walking
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int steps = 0;
  10. int maxSteps = 10000;
  11. string goingHome;
  12. int sumSteps = 0;
  13.  
  14.  
  15. while (steps < maxSteps)
  16. {
  17. goingHome = Console.ReadLine();
  18. {
  19. if (goingHome == "Going home")
  20. {
  21. goingHome = Console.ReadLine();
  22. sumSteps += int.Parse(goingHome);
  23.  
  24. if (sumSteps >= maxSteps)
  25. {
  26. Console.WriteLine("Goal reached! Good job!");
  27. break;
  28. }
  29. if (sumSteps < maxSteps)
  30. {
  31. Console.WriteLine($"{maxSteps - sumSteps} more steps to reach goal.");
  32. break;
  33. }
  34. }
  35. sumSteps += int.Parse(goingHome);
  36. if (sumSteps >= maxSteps)
  37. {
  38. Console.WriteLine("Goal reached! Good job!");
  39. }
  40. }
  41. }
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement