Each person should FIRST work on the problems below individually, then confer as a group to talk about how to do the problems. We'll collect each person's answers for credit.
struct Grocery
{
string name;
double price;
};
Write the function below.
double CartWorth(const Vector<Grocery> & cart, int num) // precondition: num = # of entries in vector cart // postcondition: returns the sum of prices of all items in cart
"Michael Jordan"
"Rebecca Lobo"
"Suzy Hamilton"
"Robert Kennedy"
Write a function PrintLastFirst that is passed such a string
as a parameter and that prints the last name, followed by a comma,
followed by the first name. For example, the function call
PrintLastFirst("Michael Jordan")
should generate the output below
Jordan, Michael
In writing PrintFirstLast you may find it useful to call the
string member function substr that returns a substring of a
given string, e.g., s = "rhinoceros"; t = s.substr(0,5);
makes the string t == "rhino".
// string substr(int pos, int len) // returns string of len chars starting at pos // truncates if len too big, returns empty string // if pos too bigComplete the function below.
void PrintFirstLast(string name) // precondition: name consists of a first name followed by // exactly one space, followed by a last name // e.g., "Leonardo daVinci" // postcondition: output: lastname comma first name // e.g., daVinci, Leonardo // NOTE: if no space in name, then "space cadet" should be printed