aggressiveviking

Untitled

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