Advertisement
viraco4a

03. Restaurant Discount

May 22nd, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 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 _03_Restaurant_Discount
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int GroupSize = int.Parse(Console.ReadLine());
  14. string Package = Console.ReadLine();
  15. double Price = 0;
  16. double discount = 0;
  17. double packagePrice = 0;
  18. CalcDiscountPackage(Package, out discount, out packagePrice);
  19.  
  20. if (GroupSize <= 50)
  21. {
  22. Price = 2500;
  23. double PricePerPerson = CalcPricePerPerson(GroupSize, Price, discount, packagePrice);
  24. Console.WriteLine("We can offer you the Small Hall");
  25. Console.WriteLine($"The price per person is {PricePerPerson:f2}$");
  26. }
  27. else if (50 < GroupSize && GroupSize <= 100)
  28. {
  29. Price = 5000;
  30. double PricePerPerson = CalcPricePerPerson(GroupSize, Price, discount, packagePrice);
  31. Console.WriteLine("We can offer you the Terrace");
  32. Console.WriteLine($"The price per person is {PricePerPerson:f2}$");
  33. }
  34. else if (100 < GroupSize && GroupSize <= 120)
  35. {
  36. Price = 7500;
  37. double PricePerPerson = CalcPricePerPerson(GroupSize, Price, discount, packagePrice);
  38. Console.WriteLine("We can offer you the Great Hall");
  39. Console.WriteLine($"The price per person is {PricePerPerson:f2}$");
  40. }
  41. else
  42. {
  43. Console.WriteLine("We do not have an appropriate hall.");
  44. }
  45. }
  46.  
  47. private static double CalcPricePerPerson(int GroupSize, double Price, double discount, double packagePrice)
  48. {
  49. return (Price + packagePrice) * (1 - discount) / GroupSize;
  50. }
  51.  
  52. private static void CalcDiscountPackage(string Package, out double discount, out double packagePrice)
  53. {
  54. if (Package == "Normal")
  55. {
  56. packagePrice = 500;
  57. discount = 0.05;
  58. }
  59. else if (Package == "Gold")
  60. {
  61. packagePrice = 750;
  62. discount = 0.1;
  63. }
  64. else
  65. {
  66. packagePrice = 1000;
  67. discount = 0.15;
  68. }
  69. }
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement