anizko

06. Cake

Apr 4th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Cake
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double w = double.Parse(Console.ReadLine());
  10.             double l = double.Parse(Console.ReadLine());
  11.  
  12.             double Cake = w * l;
  13.             double TotalCake = 0;
  14.            
  15.  
  16.             while(Cake>= TotalCake)
  17.             {
  18.                 string TakeCake = Console.ReadLine();
  19.  
  20.                 if (TakeCake != "STOP")
  21.                 {
  22.  
  23.                     TotalCake += double.Parse(TakeCake);
  24.                 }
  25.                 else
  26.                 {
  27.                     Console.WriteLine($"{Cake-TotalCake} pieces are left.");
  28.                     break;
  29.                 }
  30.             }
  31.  
  32.             if (Cake <TotalCake)
  33.             {
  34.                 Console.WriteLine($"No more cake left! You need {TotalCake-Cake} pieces more.");
  35.             }
  36.  
  37.  
  38.  
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment