Advertisement
Guest User

Untitled

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