Advertisement
nevenailievaa

07.Shopping

Nov 10th, 2024
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 KB | None | 0 0
  1. //Input
  2. double budget = double.Parse(Console.ReadLine());
  3. int videocardsCount = int.Parse(Console.ReadLine());
  4. int processorsCount = int.Parse(Console.ReadLine());
  5. int ramsCount = int.Parse(Console.ReadLine());
  6.  
  7. //Calculations
  8. double videocardsBill = videocardsCount * 250;
  9. double processordBill = processorsCount * (videocardsBill * 0.35);
  10. double ramsBill = ramsCount * (videocardsBill * 0.1);
  11.  
  12. double bill = videocardsBill + processordBill + ramsBill;
  13.  
  14. if (videocardsCount > processorsCount)
  15. {
  16.     //bill *= 0.85
  17.     bill = bill * 0.85;
  18. }
  19.  
  20. //Output
  21. if (budget >= bill)
  22. {
  23.     double remainingMoney = budget - bill;
  24.     Console.WriteLine($"You have {remainingMoney:f2} leva left!");
  25. }
  26. else
  27. {
  28.     double neededMoney = bill - budget;
  29.     Console.WriteLine($"Not enough money! You need {neededMoney:f2} leva more!");
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement