Advertisement
viraco4a

Untitled

Mar 12th, 2018
717
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Shopping
  4. {
  5. class Program
  6. {
  7. static void Main()
  8. {
  9. decimal budget = decimal.Parse(Console.ReadLine());
  10. int numberOfChocos = int.Parse(Console.ReadLine());
  11. double amountOfMilk = double.Parse(Console.ReadLine());
  12. decimal priceMilk = 2.7m;
  13. decimal priceChoco = 0.65m;
  14. decimal priceMandarin = 0.2m;
  15. int numberOfMandarin = (int)(numberOfChocos * (1 - 0.35));
  16. decimal totalCost = numberOfChocos * priceChoco + numberOfMandarin * priceMandarin + (decimal)amountOfMilk * priceMilk;
  17. decimal diff = Math.Abs(totalCost - budget);
  18. if (budget >= totalCost)
  19. {
  20. Console.WriteLine($"You got this, {diff:F2} money left!");
  21. }
  22. else
  23. {
  24. Console.WriteLine($"Not enough money, you need {diff:F2} more!");
  25. }
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement