Advertisement
silvana1303

honey winter reserves

May 22nd, 2020
58
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 exampreparation
  4. {
  5.     class exam
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double honeyNeeded = double.Parse(Console.ReadLine());
  10.             string command = Console.ReadLine();
  11.             double fullHoney = 0;
  12.  
  13.             while (command != "Winter has come")
  14.             {
  15.                 string beeName = command;
  16.                 double singleBee = 0.0;
  17.  
  18.                 for (int i = 0; i < 6; i++)
  19.                 {
  20.                     double honeyGathered = double.Parse(Console.ReadLine());
  21.                     singleBee += honeyGathered;
  22.                     fullHoney += honeyGathered;
  23.                 }
  24.  
  25.                 if (fullHoney >= honeyNeeded)
  26.                 {
  27.                     break;
  28.                 }
  29.  
  30.                 if (singleBee < 0)
  31.                 {
  32.                     Console.WriteLine($"{beeName} was banished for gluttony");
  33.                 }
  34.  
  35.                 command = Console.ReadLine();
  36.             }
  37.  
  38.             if (fullHoney >= honeyNeeded)
  39.             {
  40.                 Console.WriteLine($"Well done! Honey surplus {fullHoney-honeyNeeded:f2}.");
  41.             }
  42.             else
  43.             {
  44.                 Console.WriteLine($"Hard Winter! Honey needed {honeyNeeded-fullHoney:F2}.");
  45.             }
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement