Advertisement
Guest User

Untitled

a guest
Feb 27th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. static void main()
  2. {
  3.     int guests, busLim, busCount, tableLim, tableCount, boatLim, boatCount;
  4.  
  5.     Console.WriteLine("How many people did you invite?");
  6.     guests = int.Parse(Console.ReadLine());
  7.     Console.WriteLine("How many seats are available in a bus?");
  8.     busLim = int.Parse(Console.ReadLine());
  9.     Console.WriteLine("How many seats are available in a table?");
  10.     tableLim = int.Parse(Console.ReadLine());
  11.     Console.WriteLine("How many seats are available in a boat?");
  12.     boatLim = int.Parse(Console.ReadLine());
  13.  
  14.     busCount = CalcAmount(guests, busLim);
  15.     tableCount = CalcAmount(guests, tableLim);
  16.     boatCount = CalcAmount(guests, boatLim);
  17.  
  18.     Console.WriteLine("For {0} guests you need {1} buses, {2} tables and {3} boats", guests, busCount, tableCount, boatCount);
  19. }
  20.  
  21. public static int CalcAmount(int guests, int limit)
  22. {
  23.     int vehicles = guests/limit; // מספרת הרכבים יהיה מספר המוזמנים חלקי כמות האנשים שנכנסת לרכב אחד
  24.     if(guests % limit != 0)      // אם ישנה שארית - נוסיף עוד רכב
  25.         vehicles++;
  26.  
  27.     return vehicles;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement