Advertisement
dragonbs

Padawan Equipment

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