Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Walking
- {
- class Program
- {
- static void Main(string[] args)
- {
- int steps = 0;
- int maxSteps = 10000;
- string goingHome;
- int sumSteps = 0;
- while (steps < maxSteps)
- {
- goingHome = Console.ReadLine();
- {
- if (goingHome == "Going home")
- {
- goingHome = Console.ReadLine();
- sumSteps += int.Parse(goingHome);
- if (sumSteps >= maxSteps)
- {
- Console.WriteLine("Goal reached! Good job!");
- break;
- }
- if (sumSteps < maxSteps)
- {
- Console.WriteLine($"{maxSteps - sumSteps} more steps to reach goal.");
- break;
- }
- }
- sumSteps += int.Parse(goingHome);
- if (sumSteps >= maxSteps)
- {
- Console.WriteLine("Goal reached! Good job!");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement