Advertisement
didito33

Steps(StringToInt)

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