Advertisement
knikolov98

Untitled

Sep 25th, 2019
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.23 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Plug_WALK
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int steps = 0;
  10.             string input = String.Empty;
  11.             int stepsLeft = 0;
  12.  
  13.             bool Enough = false;
  14.  
  15.  
  16.             while (steps <= 10000)
  17.  
  18.             {
  19.                 input = Console.ReadLine();
  20.  
  21.  
  22.                 if (input == "Going home")
  23.                 {
  24.                     steps += int.Parse(Console.ReadLine());
  25.                     stepsLeft = 10000 - steps;
  26.  
  27.                     if (steps >= 10000)
  28.                     {
  29.                         Enough = true;
  30.                     }
  31.                     break;
  32.                 }
  33.                 else
  34.                 {
  35.                     steps += int.Parse(input);
  36.  
  37.                     if (steps >= 10000)
  38.                     {
  39.                         Enough = true;
  40.                         break;
  41.                     }
  42.                 }
  43.             }
  44.  
  45.             if (Enough)
  46.             {
  47.                 Console.WriteLine("Goal reached! Good job!");
  48.             }
  49.             else
  50.             {
  51.                 Console.WriteLine($"{stepsLeft} more steps to reach goal.");
  52.             }
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement