nikolayneykov

Untitled

Oct 15th, 2018
147
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 steps = 0;
  14.             string command = Console.ReadLine();
  15.  
  16.  
  17.             while (true)
  18.             {
  19.                 if (command == "Going home")
  20.                 {
  21.                     steps += int.Parse(Console.ReadLine());
  22.                     break;
  23.                 }
  24.  
  25.                 int currentSteps = int.Parse(command);
  26.                 steps += currentSteps;
  27.  
  28.                 if (steps >= 10000)
  29.                 {
  30.                     break;
  31.                 }
  32.  
  33.                 command = Console.ReadLine();
  34.             }
  35.  
  36.             if (steps < 10000)
  37.             {
  38.                 int stepsNeeded = 10000 - steps;
  39.                 Console.WriteLine($"{stepsNeeded} more steps to reach goal.");
  40.             }
  41.             else
  42.             {
  43.                 Console.WriteLine("Goal reached! Good job!");
  44.  
  45.             }
  46.  
  47.             Console.ReadLine();
  48.  
  49.         }
  50.  
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment