IvetValcheva

07. Shopping

Jan 17th, 2022
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Shopping
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. double budget = double.Parse(Console.ReadLine());
  10.  
  11. int videocardQuantity = int.Parse(Console.ReadLine());
  12. int processorsQuantity = int.Parse(Console.ReadLine());
  13. int ramMemoryQuantity = int.Parse(Console.ReadLine());
  14.  
  15. double videocardPrice = videocardQuantity * 250;
  16. double processorsPrice = processorsQuantity * (videocardPrice * 0.35);
  17. double ramMemoryPrice = ramMemoryQuantity* (videocardPrice * 0.10);
  18.  
  19. double totalPrice = videocardPrice + processorsPrice + ramMemoryPrice;
  20.  
  21. if(videocardQuantity> processorsQuantity)
  22. {
  23. totalPrice = totalPrice - (totalPrice * 0.15);
  24. }
  25.  
  26. double difference = budget - totalPrice; //300-400 =-100
  27.  
  28. if (difference >= 0)
  29. {
  30. Console.WriteLine($"You have {difference:F2} leva left!");
  31. }
  32. else
  33. {
  34. Console.WriteLine($"Not enough money! You need {Math.Abs(difference):F2} leva more!");
  35. }
  36.  
  37. }
  38. }
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment