What am I doing wrong?

...
Last edited on
Add a line to print out motorVehicle.category so you can see what value it has, and from there work out where you're not setting it correctly.
OP:


This is a project for school, and my output is supposed to be this:

Carpool:
13 occupants - No recommendation for this capacity.
12 occupants - Dodge Sprinter Wagon
11 occupants - Dodge Sprinter Wagon
10 occupants - Dodge Sprinter Wagon
9 occupants - Dodge Sprinter Wagon
8 occupants - Ford E-150 XL
7 occupants - Ford E-150 XL
6 occupants - Chrysler Town and Country
5 occupants - Chrysler Town and Country
4 occupants - Consider a smaller vehicle.
3 occupants - Consider a smaller vehicle.
2 occupants - Consider a smaller vehicle.
1 occupants - Consider a smaller vehicle.
0 occupants - No recommendation for this capacity.

(There is more to this output but I want to keep this post short)


This is the output I am getting:

Carpool:
13 occupants - Purpose unknown or not specified.
12 occupants - Purpose unknown or not specified.
11 occupants - Purpose unknown or not specified.
10 occupants - Purpose unknown or not specified.
9 occupants - Purpose unknown or not specified.
8 occupants - Purpose unknown or not specified.
7 occupants - Purpose unknown or not specified.
6 occupants - Purpose unknown or not specified.
5 occupants - Purpose unknown or not specified.
4 occupants - Purpose unknown or not specified.
3 occupants - Purpose unknown or not specified.
2 occupants - Purpose unknown or not specified.
1 occupants - Purpose unknown or not specified.
0 occupants - Purpose unknown or not specified.

So on and so on......

The problem is its not listing the cars, but it does list the number of occupants. Is there anything wrong with this code? I will post the parts I messed around with.



string GetRecommendation(Vehicle motorVehicle)

int group = GetCapacityGroup(motorVehicle.occupants);

string recommendation;

// Compare the category parameter to string constants.

if( motorVehicle.category == CARPOOL )
{
recommendation = GetCarpoolRecommendation(group);
}
else if( motorVehicle.category == FAMILY )
{
recommendation = GetFamilyRecommendation(group);
}
else if( motorVehicle.category == SPORT )
{
recommendation = GetSportRecommendation(group);
}
else
{
recommendation = "Purpose unknown or not specified.";
}

return recommendation;






void DisplayResults(string category, int occupants)
{

// TODO (Objective 3c): Declare Vehicle structure variable
Vehicle motorVehicle;

// TODO (Objective 3c): Initialize Vehicle fields with function parameter values
motorVehicle.category;
motorVehicle.occupants;


// TODO (Objective 3c): Replace function call arguments with 1 Vehicle structure variable
string recommendation = GetRecommendation(motorVehicle);


cout << setw(12) << occupants << " occupants - "
<< recommendation << endl;
}
Topic archived. No new replies allowed.