Advertisement
sanyakasarova

06. Cake

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