Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void main()
- {
- int guests, busLim, busCount, tableLim, tableCount, boatLim, boatCount;
- Console.WriteLine("How many people did you invite?");
- guests = int.Parse(Console.ReadLine());
- Console.WriteLine("How many seats are available in a bus?");
- busLim = int.Parse(Console.ReadLine());
- Console.WriteLine("How many seats are available in a table?");
- tableLim = int.Parse(Console.ReadLine());
- Console.WriteLine("How many seats are available in a boat?");
- boatLim = int.Parse(Console.ReadLine());
- busCount = CalcAmount(guests, busLim);
- tableCount = CalcAmount(guests, tableLim);
- boatCount = CalcAmount(guests, boatLim);
- Console.WriteLine("For {0} guests you need {1} buses, {2} tables and {3} boats", guests, busCount, tableCount, boatCount);
- }
- public static int CalcAmount(int guests, int limit)
- {
- int vehicles = guests/limit; // מספרת הרכבים יהיה מספר המוזמנים חלקי כמות האנשים שנכנסת לרכב אחד
- if(guests % limit != 0) // אם ישנה שארית - נוסיף עוד רכב
- vehicles++;
- return vehicles;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement