fumanbest

Walking

Oct 13th, 2018
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Walking
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int allSteps = 0;
  14.             string command = string.Empty;
  15.             while (true)
  16.             {
  17.                 command = Console.ReadLine();
  18.                 if (command == "Going home")
  19.                 {
  20.                     int stepsToHome = int.Parse(Console.ReadLine());
  21.                     allSteps += stepsToHome;
  22.                     break;
  23.                 }
  24.                 int steps = int.Parse(command);
  25.                 allSteps += steps;
  26.                 if (allSteps >= 10000)
  27.                 {
  28.                     break;
  29.                 }
  30.             }
  31.             if (allSteps >= 10000)
  32.             {
  33.                 Console.WriteLine("Goal reached! Good job!");
  34.             }
  35.             else
  36.             {
  37.                 int diffSteps = 10000 - allSteps;
  38.                 Console.WriteLine($"{diffSteps} more steps to reach goal.");
  39.             }
  40.  
  41.         }
  42.     }
  43. }
Add Comment
Please, Sign In to add comment