Advertisement
IvanITD

07.Shopping

Jan 15th, 2024
663
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | Source Code | 0 0
  1. double petarBudget = double.Parse(Console.ReadLine());
  2. int GPUAmount = int.Parse(Console.ReadLine());
  3. int CPUAmount = int.Parse(Console.ReadLine());
  4. int RAMAmount = int.Parse(Console.ReadLine());
  5.  
  6.  
  7. double GPUPrice = GPUAmount * 250;
  8. double CPUPrice = (GPUPrice * 0.35) * CPUAmount;
  9. double RAMPrice = (GPUPrice * 0.10) * RAMAmount;
  10.  
  11. double totalPrice = GPUPrice + CPUPrice  + RAMPrice;
  12.  
  13. if (GPUAmount > CPUAmount)
  14. {
  15.     totalPrice -= totalPrice * 0.15;
  16. }
  17.  
  18.  
  19. if (totalPrice <= petarBudget)
  20. {
  21.     Console.WriteLine($"You have {petarBudget - totalPrice:F2} leva left!");
  22. }
  23. else if (totalPrice > petarBudget)
  24. {
  25.     Console.WriteLine($"Not enough money! You need {Math.Abs(petarBudget - totalPrice):F2} leva more!");
  26. }
  27.  
Tags: C#
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement