Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // input
- double money = double.Parse(Console.ReadLine()!);
- int students = int.Parse(Console.ReadLine()!);
- double lightsaberPrice = double.Parse(Console.ReadLine()!);
- double robePrice = double.Parse(Console.ReadLine());
- double beltPrice = double.Parse(Console.ReadLine()!);
- // • Lightsaber
- double lightsabers = Math.Ceiling((double)students * 1.10); //Tук няма как да умножиш students по 1.10, тъй като е int, а не double, затова го правиш на double със скобите пред него най-просто
- double sumLightsabers = lightsabers * lightsaberPrice;
- // Robe
- double sumRobes = students * robePrice;
- // • Belt
- double belts = students;
- double sumBelts = belts * beltPrice;
- //if (students >= 6)
- //{
- // double beltsDiscount = belts / 6;
- // sumBelts = (belts - beltsDiscount) * beltPrice;
- // Това не е правилно решение, това отдолу е:
- double sixthBelts = Math.Floor((double) students / 6); // Така виждаш колко пъти имаш шести колан
- sumBelts = (students * beltPrice) - (sixthBelts * beltPrice);
- // total
- double totalSum = sumRobes + sumLightsabers + sumBelts;
- if (totalSum <= money)
- {
- Console.WriteLine($"The money is enough - it would cost {totalSum:f2}lv.");
- }
- else
- {
- Console.WriteLine($"John will need {totalSum - money:f2}lv more.");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement