Question: C++: please solve them step by step. part by part. thanks 1) Create a struct Carpool to represent a carpool group. Your struct should include
C++: please solve them step by step. part by part.
thanks
1) Create a struct Carpool to represent a carpool group. Your struct should include an array of the names of the people in the group, the number of people in the group, and when they arrive at work (Using the Time struct provied here:)
struct Time{//military time, no am/pm
int hour;
int minute;
};
Time earlier(Time t1, Time t2){
Time ret;
if(t1.hour == t2.hour){
if(t1.minute
ret = t1;
else
ret = t2;
}
else if(t1.hour
ret = t1;
}
else{
ret = t2;
}
return ret;
}
Since most cars only hold 5 passengers, that will be the maximum size of a carpool group.
2) In part 3, you will write a function Carpool combineCarpool(Carpool car1, Carpool car2) as described below.
If car1 and car2 have no more than 5 people all together, create a new Carpool which includes all members of both carpools, and arrives at the earlier of the two arrival times. If there are too many members to combine them, return a Carpool with zero members. You may use the function earlier provided here:
struct Time{//military time, no am/pm
int hour;
int minute;
};
Time earlier(Time t1, Time t2){
Time ret;
if(t1.hour == t2.hour){
if(t1.minute
ret = t1;
else
ret = t2;
}
else if(t1.hour
ret = t1;
}
else{
ret = t2;
}
return ret;
}
3) Write the combineCarpool function described above. Write a sensible main function that tests your code, and run it a few times to make sure it works.
4) Create a NEW FILE and copy-paste over your code from parts 1 and 2. Now convert Carpool in to a class. For now, you can make all your variables public. Write a member function called print that prints out the names of everyone in the carpool. Write a sensible main function that tests your code, and run it a few times to make
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
