Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 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. float budget = float.Parse(Console.ReadLine());
  10. double students = double.Parse(Console.ReadLine());
  11. float saberPrice = float.Parse(Console.ReadLine());
  12. float robesPrice = float.Parse(Console.ReadLine());
  13. float 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 = (int)students / 6;
  22. double totalBeltsPrice = beltsPrice * (students - totalFreeBelts);
  23. double totalMoneyNeed = totalSaberPrice + totalRobesPrice + totalBeltsPrice;
  24.  
  25. if (totalMoneyNeed > budget)
  26. {
  27. Console.WriteLine($"Ivan Cho will need {totalMoneyNeed-budget:f2}lv more.");
  28. }
  29. else
  30. {
  31. Console.WriteLine($"The money is enough - it would cost {totalMoneyNeed:f2}lv.");
  32. }
  33.  
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement