Advertisement
desislavg

Untitled

May 19th, 2019
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 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 maxSteps = 10000;
  10. string goingHome;
  11. int sumSteps = 0;
  12.  
  13.  
  14. while (sumSteps < maxSteps)
  15. {
  16. goingHome = Console.ReadLine();
  17. {
  18. if (goingHome == "Going home")
  19. {
  20. goingHome = Console.ReadLine();
  21. sumSteps += int.Parse(goingHome);
  22.  
  23. if (sumSteps >= maxSteps)
  24. {
  25. Console.WriteLine("Goal reached! Good job!");
  26. break;
  27. }
  28. if (sumSteps < maxSteps)
  29. {
  30. Console.WriteLine($"{maxSteps - sumSteps} more steps to reach goal.");
  31. break;
  32. }
  33. }
  34. sumSteps += int.Parse(goingHome);
  35. if (sumSteps >= maxSteps)
  36. {
  37. Console.WriteLine("Goal reached! Good job!");
  38. }
  39. }
  40. }
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement