Advertisement
YavorJS

Sweet Dessert 90%

Sep 12th, 2016
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 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 _1.Sweet_Dessert
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. decimal cash = decimal.Parse(Console.ReadLine());
  14. int guests = int.Parse(Console.ReadLine());
  15. decimal bananasPrice = decimal.Parse(Console.ReadLine());
  16. decimal eggsPrice = decimal.Parse(Console.ReadLine());
  17. decimal berriesPrice = decimal.Parse(Console.ReadLine());
  18.  
  19.  
  20. int sets = 1;
  21. if (guests <= 6)
  22. {
  23. sets = 1;
  24. }
  25. else if (guests > 6)
  26. {
  27. int numberOfGuests = guests;
  28. while (numberOfGuests > 6)
  29. {
  30. sets++;
  31. numberOfGuests = numberOfGuests - 6;
  32. }
  33. }
  34. decimal priceOfSet = 2 * bananasPrice + 4 * eggsPrice + 0.2m * berriesPrice;
  35. decimal totalPrice = sets * priceOfSet;
  36.  
  37. if (cash >= totalPrice)
  38. {
  39. Console.WriteLine("Ivancho has enough money - it would cost {0:f2}lv.", totalPrice);
  40. }
  41. else
  42. {
  43. Console.WriteLine("Ivancho will have to withdraw money - he will need {0:f2}lv more.", totalPrice - cash);
  44. }
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement