Guest User

Walking

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