can someone write me the following program
suppose you have a group of people who need to be transportated on buses and vans. you can charter a bus only if u can fill it. a bus holds 50 peopel. you must provide vans for the 49 people or less who will be left over after you charter buses. wrtite a program that acepsts a number of peopel left over that must be chartered and reports the number of people left over that must be placed on vans. hint u must use the modulus operator.
C++ program need help?
Do the program yourself. We'll help with specific questions. Its good for you to at least try to take a swat at it.
Reply:void Busses(int TotalNumberofPeople) {
int Vans = TotalNumberofPeople - 50; //number of people who need vans
int SeatsinVan; //number of people the van can take
cout%26lt;%26lt;"Total # of people needing Vans "%26lt;%26lt;Vans%26lt;%26lt;endl;
if(Vans % SeatsinVan == 0) { //No Remainder
cout%26lt;%26lt;"Number of Vans Needed "%26lt;%26lt;Vans/SeatsinVan%26lt;%26lt;endl;
}
else {
cout%26lt;%26lt;"Number of Vans Needed "%26lt;%26lt;(Vans/SeatsinVan)+1%26lt;%26lt;endl;
}
return;
}
Reply:#include %26lt;iostream%26gt;
#include %26lt;conio.h%26gt;
using namespace std;
int main() {
int ppl;
cout%26lt;%26lt;"How many people in all? ";
cin%26gt;%26gt;ppl;
cout%26lt;%26lt;endl%26lt;%26lt;ppl%50%26lt;%26lt;" people are left over";
getch();
}
buy flowers
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment