Advertisement
Guest User

04. Walking

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