Advertisement
Dikov

Untitled

Mar 5th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace P04_Cake
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. double lenght = double.Parse(Console.ReadLine());
  14. double width = double.Parse(Console.ReadLine());
  15.  
  16. double cake = lenght * width;
  17. double needed = 0;
  18.  
  19.  
  20.  
  21. while (true)
  22. {
  23.  
  24. string current = Console.ReadLine();
  25. if (current == "STOP")
  26. {
  27. Environment.Exit(0);
  28. }
  29. double pieces = double.Parse(Console.ReadLine());
  30. if (cake >= pieces)
  31. {
  32. cake -= pieces;
  33. if (cake == 0)
  34. {
  35. Console.WriteLine(cake);
  36. Environment.Exit(0);
  37. }
  38.  
  39. }
  40. if (pieces > cake)
  41. {
  42. needed = pieces - cake;
  43. break;
  44. }
  45.  
  46. }
  47. Console.WriteLine($"No more cake left! You need {needed} pieces more.");
  48.  
  49.  
  50.  
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement