Advertisement
aggressiveviking

Untitled

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