Advertisement
Guest User

Untitled

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