Advertisement
Lyubohd

Everest

Dec 6th, 2018
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.32 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ExamPractice
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int countDays = 1;
  10.             int attitudeReached = 5364;
  11.             int attitudeEverest = 8848;
  12.  
  13.             string command = Console.ReadLine();
  14.             int metersClimbed = 0;
  15.  
  16.             while (true)
  17.             {
  18.                 if (command == "END")
  19.                 {
  20.                     break;
  21.                 }
  22.                 else if (command == "Yes")
  23.                 {
  24.                     countDays++;
  25.                 }
  26.                
  27.                 if (countDays > 5)
  28.                 {
  29.                     break;
  30.                 }
  31.  
  32.                 metersClimbed = int.Parse(Console.ReadLine());
  33.                 attitudeReached += metersClimbed;
  34.  
  35.                 if (attitudeReached >= attitudeEverest)
  36.                 {
  37.                     break;
  38.                 }
  39.  
  40.                 command = Console.ReadLine();
  41.             }
  42.  
  43.             if (attitudeReached >= attitudeEverest)
  44.             {
  45.                 Console.WriteLine($"Goal reached for {countDays} days!");
  46.             }
  47.             else
  48.             {
  49.                 Console.WriteLine("Failed!");
  50.                 Console.WriteLine($"{attitudeReached}");
  51.             }
  52.  
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement