Advertisement
nevenailievaa

09.PadawanEquipment

Jan 14th, 2023
119
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.85 KB | None | 1 0
  1. //INPUT
  2. double stockMoney = double.Parse(Console.ReadLine());
  3. int studentsCnt = int.Parse(Console.ReadLine());
  4. double lightsaberPrice = double.Parse(Console.ReadLine());
  5. double robePrice = double.Parse(Console.ReadLine());
  6. double beltPrice = double.Parse(Console.ReadLine());
  7.  
  8. //ACTION
  9. double percent10lightsabersStudents = Math.Ceiling(studentsCnt * 0.1);
  10. double lightsabers = (studentsCnt + percent10lightsabersStudents) * lightsaberPrice;
  11. double robes = studentsCnt * robePrice;
  12. double sixthBelts = Math.Floor((double)studentsCnt / 6);
  13. double belts = (studentsCnt * beltPrice) - (sixthBelts * beltPrice);
  14.  
  15. double sum = lightsabers + robes + belts;
  16.  
  17. //OUTPUT
  18. if (stockMoney >= sum)
  19. {
  20.     Console.WriteLine($"The money is enough - it would cost {sum:f2}lv.");
  21. }
  22. else
  23. {
  24.     Console.WriteLine($"John will need {sum - stockMoney:f2}lv more.");
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement