anizko

04. Walking

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