Need help getting started! What should I do first?

Create a program to use the Car structure.

The structure Car is declared as follows:
struct Car
{
string carMake;
string carModel;
int yearModel;
double cost;
};
Write a definition statement that defines a Car structure variable initialized with the
following data:
Make: Ford
Model: Mustang
Year Model: 1968
Cost: $20,000

Modify the Car structure to include a field called Purpose which is of an enumerated type that is either BUSINESS or PERSONAL.

a) Create a main function that defines an array of 10 Car structure variables and initialize the first three elements with the following data:
Make Model Year Cost Purpose
Ford Taurus 1997 21,000.00 BUSINESS
Honda Accord 1992 11,000.00 BUSINESS
Lamborghini Aventador 2011 390,000.00 PERSONAL

b) Using descriptive prompts, read user input for the member values of one additional Car structure variable in the array. Thus, the array of Car structure variables should have a total of 4 elements: 3 initialized and 1 user input.

c) Create a displayCar function that takes a single Car structure variable parameter and uses descriptive output to display the member values to standard output: Make,Model, Year, Cost, and Purpose. Floating point data should be displayed with 2 digits of precision after the decimal point. The enumerated fields should be displayed with a string indicating the purpose: BUSINESS or PERSONAL.

d) In the main function, use a loop to display the member values for each of the
initialized Car structure variables in the array using the displayCar function.
@aa1994
The homework is given by a teacher, you should do it easily if you pay enough attention to class.

Anyways,
Modify the Car structure to include a field called Purpose which is of an enumerated type that is either BUSINESS or PERSONAL.

This is the one you should do first. You need to declare an enum member inside the Car class. Be sure to have these enum attributes declared, BUSINESS and PERSONAL.

Though the public forum is the place to help students with C++ learning not the place to give straight solutions to homework. But I am happy with both ways if you ask me the right place.

Good luck!
Last edited on
Thanks for the suggestion. I do not expect anyone to complete my assignment for me. That is why I asked for suggestions on how to start.

So you declare an enum type :
1
2
3
4
5
enum Personal
{
    BUSINESS = 1,
    PERSONAL = 2
};


The rest is how you use this enum type in your class declaration.
Can I also do it like this?

1
2
// enumerated type to hold purpose of car
enum Purpose { BUSINESS, PERSONAL};
> Can I also do it like this?
No problem, it is acceptable.
How did the assignment go? Still need help?
Topic archived. No new replies allowed.