Advertisement
desislava_topuzakova

06. Honey Winter Reserves

Jun 10th, 2020
1,185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _06._Honey_Winter_Reserves
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double quantity = double.Parse(Console.ReadLine());
  10.             String name = Console.ReadLine();
  11.             while (name != "Winter has come")
  12.             {
  13.                 double total = 0;
  14.                 for (int i = 1; i <= 6; i++)
  15.                 {
  16.                     double collectedHoney = double.Parse(Console.ReadLine());
  17.                     total += collectedHoney;
  18.                 }
  19.                 if (total < 0)
  20.                 {
  21.                     Console.WriteLine($"{name} was banished for gluttony");
  22.                 }
  23.  
  24.                 quantity -= total;
  25.                 if (quantity <= 0)
  26.                 {
  27.                     break;
  28.                 }
  29.                 name = Console.ReadLine();
  30.             }
  31.  
  32.             if (quantity > 0)
  33.             {
  34.                 Console.WriteLine($"Hard Winter! Honey needed {quantity:F2}.");
  35.             }
  36.             else
  37.             {
  38.                 Console.WriteLine($"Well done! Honey surplus {Math.Abs(quantity):F2}.");
  39.             }
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement