Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. using System;
  2.  
  3. class MainClass {
  4.   public static void Main (string[] args)
  5.   {
  6.       int width = int.Parse(Console.ReadLine());
  7.       int hight = int.Parse(Console.ReadLine());
  8.       int piceOfCake = 0;
  9.  
  10.       int cakeDimension = width * hight;
  11.  
  12.       while (true)
  13.       {
  14.         string input = Console.ReadLine();
  15.         if (input == "STOP")
  16.         {
  17.           break;
  18.         }
  19.         else
  20.         {
  21.             piceOfCake = int.Parse(input);
  22.             cakeDimension -= piceOfCake;
  23.             if(cakeDimension <= 0)
  24.             {
  25.               break;
  26.             }
  27.         }
  28.       }
  29.  
  30.       if (cakeDimension <= 0)
  31.       {
  32.         Console.WriteLine("No more cake left! You need " + Math.Abs(cakeDimension)+ " pieces more.");
  33.       }
  34.       else
  35.       {
  36.         Console.WriteLine(cakeDimension + " pieces are left.");
  37.       }
  38.  
  39.   }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement