Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace homeworkloops2
- {
- class Program
- {
- static void Main(string[] args)
- {
- // 10 000 steps a day
- // when tired == Going home
- // if steps >= 10 000 == goal reached
- // diff between goal and steps == more steps to reach goal
- int goal = 10000;
- int sum = 0;
- Boolean lastSteps = false;
- while (true)
- {
- string steps = Console.ReadLine();
- if ("Going home" == steps)
- {
- lastSteps = true;
- continue;
- }
- int num = int.Parse(steps);
- sum += num;
- if (sum >= goal || lastSteps)
- {
- break;
- }
- }
- if (sum >= goal)
- {
- Console.WriteLine("Goal reached! Good job!");
- }
- else
- {
- Console.WriteLine($"{goal - sum} more steps to reach goal.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement