Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _04._Walking
- {
- class Program
- {
- static void Main(string[] args)
- {
- string command = Console.ReadLine();
- int totalSteps = 0;
- bool didReachTheeGoal = false;
- while (command != "Going home")
- {
- int steps = int.Parse(command);
- totalSteps += steps;
- if (totalSteps >= 10000)
- {
- didReachTheeGoal = true;
- break;
- }
- command = Console.ReadLine();
- }
- if (didReachTheeGoal)
- {
- int stepsOver = totalSteps - 10000;
- Console.WriteLine("Goal reached! Good job!");
- Console.WriteLine($"{stepsOver} steps over the goal!");
- }
- else
- {
- int aditionalSteps = int.Parse(Console.ReadLine());
- totalSteps += aditionalSteps;
- if (totalSteps >= 10000)
- {
- int stepsOver = totalSteps - 10000;
- Console.WriteLine("Goal reached! Good job!");
- Console.WriteLine($"{stepsOver} steps over the goal!");
- }
- else
- {
- int stepsToGoal = 10000 - totalSteps;
- Console.WriteLine($"{stepsToGoal} more steps to reach goal.");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement