A car dealer ship program

Hey guys I seriously need your help

I have a project from school, and I have to create a c++ program where I gotta make this car dealership program with arrays and I'm seriously not that great with it so can someone help me out by making a program ...pleaseee



Thanks anyway for looking into this and your help would be greatly appreciated
What are the homework instructions? How much code have you done on the homework so far? If so, can you post the draft code?
I have to start but I have information about all the cars that I am gonna put in the dealership, so what I'm planning to do is ask the user to select what type of car he needs (SUV, sedan, etc)
and once he selects ill show the different companies from which he can select a model and ill show the rest of the details .....that's what I'm planning but I've got no idea how to do it if I get this program right it would help a lot in getting good grades..plz do help me and if anything else is needed I can tell you ...(btw my teacher hasn't taught us about 'class' he's taught us only about strings so I cant use class ) plz do help me
You would need a class for this, only if the homework instruction requires to create a class explicitly. But it is useful to do so. You could create a struct, which is just another name for a class.

1
2
3
4
5
6
7
8
9
10
/// Stores car data
struct car
{
   int dealercode;
   int model;
   int year;
   int price;

   /// ...
};



Now, create an array of the struct:

1
2
   /// max 10 cars
   car   cars[10];



Then, input the data:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
int main()
{
   int row = 0;

   while (true) 
   {
        /// Create a car.
        car c;

        cout << "Enter dealer code: ";
        cin >> c.dealercode;

        if (!c.dealercode)
            break;

        cout << "\nEnter model code: ";
        cin >> c.model;

        cout << "\nEnter year: ";
        cin >> c.year;

        cout << "\nEnter price: ";
        cin >> c.price;

       /// ...

       cars[row++] = c;

      if (row == 9)
         break;
   }

   /// print the data or process it
}
Thanx for that it really helped a lot but the program that I want to make I wish it was a little bit more complex so I've got engine type, transmission type and things about the car where do I stuff all this?im selling the car so you know all the details for it ....
Last edited on
Modify the car struct to add members for each of the pieces of information you are interested in.
okay thanxx :))))
Topic archived. No new replies allowed.