Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _09._Padawan_Equipment
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. double budget = float.Parse(Console.ReadLine());
  10. double students = double.Parse(Console.ReadLine());
  11. double saberPrice = float.Parse(Console.ReadLine());
  12. double robesPrice = float.Parse(Console.ReadLine());
  13. double beltsPrice = float.Parse(Console.ReadLine());
  14.  
  15. //we should buy 10% more sabers
  16. //every 6th belt is free
  17.  
  18. double numSabers = Math.Ceiling(students + (students * 0.10));
  19. double totalSaberPrice = saberPrice * numSabers;
  20. double totalRobesPrice = robesPrice * students;
  21. int totalFreeBelts = 0;
  22. if (students>=6)
  23. {
  24. totalFreeBelts = (int)students / 6;
  25. }
  26.  
  27. double totalBeltsPrice = beltsPrice * (students - totalFreeBelts);
  28. double totalMoneyNeed = totalSaberPrice + totalRobesPrice + totalBeltsPrice;
  29.  
  30. if (totalMoneyNeed > budget)
  31. {
  32. Console.WriteLine($"Ivan Cho will need {totalMoneyNeed-budget:f2}lv more.");
  33. }
  34. else
  35. {
  36. Console.WriteLine($"The money is enough - it would cost {totalMoneyNeed:f2}lv.");
  37. }
  38.  
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement