My name's makhtar new member. i was looking at the website and really like it. talking about that i have a huge problem and i need help. Can somebody help me urgently.

You are to develop a program for an auto dealership. This program will keep track of the auto inventory using an array of objects. The dealer has a limit of 100 cars in inventory at one time due to space restrictions. The class used to instantiate the auto objects must contain at a minimum the following information:
• Dealer inventory number (starting at 1000)
• Auto VIN
• Make
• Model
• Exterior color
• Interior color
• Transmission type
• Engine size in cubic inches
• Wholesale price
• Retail price
You program must present the user with a menu allowing the entry of new automobiles as they are received and remove the automobiles as they are sold. You must provide methods to search the array for cars of a particular make or model or dealer inventory number. These methods must overload the == operator. When a match is found all attributes of the car will be displayed. If a match is not found the appropriate message should be displayed.
You must provide a method to display the total number of cars in inventory.
You should provide private helper methods to check for the correct entry of numbers for the wholesale and retail prices.

If you really like this site well enough you would read the rules.

No code = no work = no help.

commented: well said :) +1

My name's makhtar new member. i was looking at the website and really like it. talking about that i have a huge problem and i need help. Can somebody help me urgently.

You are to develop a program for an auto dealership. This program will keep track of the auto inventory using an array of objects. The dealer has a limit of 100 cars in inventory at one time due to space restrictions. The class used to instantiate the auto objects must contain at a minimum the following information:
• Dealer inventory number (starting at 1000)
• Auto VIN
• Make
• Model
• Exterior color
• Interior color
• Transmission type
• Engine size in cubic inches
• Wholesale price
• Retail price
You program must present the user with a menu allowing the entry of new automobiles as they are received and remove the automobiles as they are sold. You must provide methods to search the array for cars of a particular make or model or dealer inventory number. These methods must overload the == operator. When a match is found all attributes of the car will be displayed. If a match is not found the appropriate message should be displayed.
You must provide a method to display the total number of cars in inventory.
You should provide private helper methods to check for the correct entry of numbers for the wholesale and retail prices.

I really like you and I really am looking forward to write your code for you.
Unluckily, I am too lazy to do your homework so I think I'll start a new thread waiting for someone to write my post for me.
Good luck! :)

This is an assignment to demonstrate your knowledge of c++ classes. If you know absolutely nothing about them then you probably have not paid attention in class and/or bothered to study your textbook.

Start out by defining a class with the attributes and methods mentioned in the assignment. Here is a start

class Inventory
{
   // your code goes here

};

The rest is up to you. When you have some code of your own you can post it here and ask whatever questions you may have about it.

Alright guys. I've been working on the program, bu ti got some errors. here is what i got so far. we had to write in ADT( abstract data type).

Header file

#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <cctype>
#include <cstdlib>
#include <string>
using namespace std;

class cars
{
private:
	int dealer_inventory;
	string make;
	string model;
	string *me;
	string *mj;
    int count;
	string exterior_color;
	string interior_color;
	string transmission_type;
	int engine_size;
	int wholesale_price;
	int retail_price;
    int auto_vin;
public:
	void enter_make();
	void enter_model();
	void enter_dealer();
	void p();
	void r();
	void q();
	friend istream& operator >>(istream& ins, cars& mercedes);
	friend ostream& operator <<(ostream& outs, cars& mercedes);
	friend bool operator == (cars& any, cars& mercedes);
    friend void deletearray();
    



};

CPP file


// car dealership.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "thecar.h"


using namespace std;
int main()
{
    int count;
	int i = 1;
	int choice();
	int search_type();
	bool keep_going();
	bool yes = true;
   
	
	cars mercedes[100], any;
 
	while (yes = true)
	{
	switch(choice())
	{
	case 1:
		for(count = i ; count < 100; count++) 
		{
			cin >> mercedes[count];
		
		if (keep_going())
			continue;
		else
        i = count;
		break;
		}
		break;

	
	case 2:
		int num;
		char choice;
	int invent;
	cout << "What car do you want to delete? "<< endl;
		cout << "enter inventory number" << endl;
		cin >> num;
		invent = num - 1000;
		cout << "Do you really want to delete" << mercedes[invent] << " ?  (y/n)";
		cin >> choice;
		if (choice == 'y')
			for (count = invent; count+1 < i + 1; count++)
				mercedes[count] = mercedes[count + 1];
		mercedes[i].r();

		break;

	case 3:
		switch(search_type())
		{
		case 1: 
			cout << "MAKE :";
			any.enter_make();
			for (count = 1; count < i; count++)
			{
				mercedes[count].p();
              
			  if(any == mercedes[count])
				  cout << 1000 + count <<  mercedes[count] << endl;

			}
				break;

			case 2 :
				cout << "MODEL:";
				any.enter_model();
				for (count = 1; count < i; count++)
				{
					mercedes[count].q();
					if(any == mercedes[count])
						cout << mercedes[count] << endl;
				}
				break;
			case 3:
				for (count = 1; count <= i; count++)
					cout << mercedes[count] << endl;
				break;

		}

		break;
	case 4:
		return 0;
		break;
	}
	}




return 0;
}

IMPLEMENTATION FILE

#include "stdafx.h"
#include "thecar.h"
#include <iostream>
#include <string>
using namespace std;

int choice()
{
		int start;

	do{
cout << "                  "<< "*******MENU********" << endl;
cout << "                  "<< "* enter a car : 1 *" << endl;
cout << "                  "<< "* delete a car: 2 *" << endl;
cout << "                  "<< "* search a car: 3 *" << endl;
cout << "                  "<< "* exit        : 4 *" << endl;
cout << "                  "<< "*******************" << endl;
cin >> start;
	}
while ((start!=1) && (start != 2) && (start != 3) && (start!=4));


return start;
}

int search_type()
{int start;
   
	cout << "search by make:1" << endl;
	cout << "search by  model:2" << endl;
	cout << "show all cars:3" << endl;
	
cin >> start;
return start;
}

bool operator == (cars& any, cars& mercedes)
{int k;
for (k = 0; k<(strlen(mercedes.mj)); k++)
{
return (any.me[k] == mercedes.mj[k]);
}
}

istream& operator >>(istream& ins, cars& mercedes)
{
	cout << "enter make :" << endl;
	cin >> mercedes.make;
	cout << "enter model : " << endl;
	cin >> mercedes.model;
	cout << "enter exterior color :" << endl;
	cin >> mercedes.exterior_color;
	cout << "enter interior color :" << endl;
	cin >> mercedes.interior_color;
	cout << " enter transmission type" << endl;
	cin >> mercedes.transmission_type;
	cout << "enter engine size " << endl;
	cin >> mercedes.engine_size;
	cout << "enter wholesale price" << endl;
	cin >> mercedes.wholesale_price;
	cout << "enter retail price" << endl;
	cin >> mercedes.retail_price;
	
return ins;
}

ostream& operator << (ostream& outs, cars& mercedes)
{
	outs <<  "|"<< mercedes.make << "|"<< mercedes.model <<"|" << mercedes.exterior_color << "|" << mercedes.interior_color<< "|" << mercedes.engine_size<<"|"<< mercedes.transmission_type << "|" << mercedes.wholesale_price << "|" << mercedes.retail_price;
//cout << endl;
return outs;
}

void cars::p()
{
	mj = make;

}

void cars::q()
{
mj = model;
}

void cars::r()
{

for(count=0; count <5; count++)
{make[count] = '#';
model[count] = '#';
}

}

void cars::enter_make()
{
cin >> make;
me = make;
}

void cars::enter_model()
{
	cin >> model;
	me = model;

}
bool keep_going()
{
	char start;
	bool stop;
	
	cout << "Do you want to enter more cars? (y/n) " << endl;
	cin >> start;
	if (start=='y')
		stop = true;
	else
		stop = !true;



return stop;
}

ERRORS


------ Build started: Project: car dealership, Configuration: Debug Win32 ------
Compiling...
implementation.cpp
c:\documents and settings\makhtar\my documents\visual studio 2008\projects\car dealership\car dealership\implementation.cpp(39) : error C2664: 'strlen' : cannot convert parameter 1 from 'std::string *' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\makhtar\my documents\visual studio 2008\projects\car dealership\car dealership\implementation.cpp(76) : error C2440: '=' : cannot convert from 'std::string' to 'std::string *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
c:\documents and settings\makhtar\my documents\visual studio 2008\projects\car dealership\car dealership\implementation.cpp(82) : error C2440: '=' : cannot convert from 'std::string' to 'std::string *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
c:\documents and settings\makhtar\my documents\visual studio 2008\projects\car dealership\car dealership\implementation.cpp(98) : error C2440: '=' : cannot convert from 'std::string' to 'std::string *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
c:\documents and settings\makhtar\my documents\visual studio 2008\projects\car dealership\car dealership\implementation.cpp(104) : error C2440: '=' : cannot convert from 'std::string' to 'std::string *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Build log was saved at "file://c:\Documents and Settings\Makhtar\My Documents\Visual Studio 2008\Projects\car dealership\car dealership\Debug\BuildLog.htm"
car dealership - 5 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

You need to read the error messages, look at the line, and learn how to fix the problem. For example:

line 39: why are you calling strlen() to get the length of std::string? You don't have to do that -- just call std::string's length() function for (k = 0; k<(mercedes.mj.length() ); k++)

You need to read the error messages, look at the line, and learn how to fix the problem. For example:

line 39: why are you calling strlen() to get the length of std::string? You don't have to do that -- just call std::string's length() function for (k = 0; k<(mercedes.mj.length() ); k++)

i try to read my errors, but no success. i tryed to fix them, no success

i try to read my errors, but no success

Does this mean you have become blind?
If not, consult at least an ophthalmologist. Maybe he/she can help you(with a pair of glasses) so you can read your error messages again.

commented: well said :) +1
commented: my thoughts too :) +36

i try to read my errors, but no success

I hope you didn't take this literally.

i try to read my errors, but no success. i tryed to fix them, no success

Post your attempt to fix one of the errors. Only try to fix the errors one at a time. Correct an error, compile, and correct again if its still wrong. Once that error is corrected go on the the next error.

c:\documents and settings\makhtar\my documents\visual studio 2008\projects\car dealership\car dealership\implementation.cpp(39) : error C2664: 'strlen' : cannot convert parameter 1 from 'std::string *' to 'const char *'

That is telling you that the error occurs on line 39 in the file implementation.cpp. Then it says the function 'strlen' takes an argument that is 'const char *', not 'std::string *' as you tried to pass it. If you look at that line in your program you will see what the error message is talking about -- you passed a pointer to std::string.

This what i did. i remove the pointers. it got me to 1 error now. the same. i am still working on the same mistake
c:\documents and settings\makhtar\my documents\visual studio 2008\projects\car dealership\car dealership\implementation.cpp(39) : error C2664: 'strlen' : cannot convert parameter 1 from 'std::string *' to 'const char *'

Just to remind you guys. i am still in school and trying my best.

A good way to go about it sometimes is to only consider the first error line. And then if you can't solve that look at the next line and see how that error might relate to the previous one.

You need to understand the error messages; if you do not like the format of the errors, try compiling on a different compiler to get a different looking error.

error C2664: 'strlen' : cannot convert parameter 1 from 'std::string *' to 'const char *'

For example, an error like this one, you're trying to pass a std:string as a parameter to a function that accepts a const char* as a parameter.

i seriously tried but still cannot find the mistake. Can somebody help me please

>i seriously tried but still cannot find the mistake
Huh? What do you mean you can't find it? You have been told exactly what your error is, and how to solve it. What more could you want?

Read through the posts, and actually pay attention to what is being said. :icon_rolleyes:

Please don't PM me for help.

error C2664: 'strlen' : cannot convert parameter 1 from 'std::string *' to 'const char *'

To fix this error, try to understand what exactly is wrong. You are passing the datatype std::string* to the function strlen, which will ONLY accept the datatype const char*.

bool operator ==(cars& any, cars& mercedes) {
   int k;
   for (k = 0; k < (strlen(mercedes.mj)); k++) {
      return (any.me[k] == mercedes.mj[k]);
   }
}

As you are using std::string's, I see no appropriate reason to use the strlen function as there is already a .length() member as part of the std::string class. Also, mercedes.mj appears to be a pointer to an std::string, so as long as the pointer is valid, you can find the length of the string like this:

mercedes.mj->length()

And when applied to your code, this should work:

bool operator ==(cars& any, cars& mercedes) {
   int k;
   for (k = 0; k < mercedes.mj->length(); k++) {
      return (any.me[k] == mercedes.mj[k]);
   }
}

Then I also realized, though it isn't causing any errors, this line is also wrong.

return (any.me[k] == mercedes.mj[k]);

Both any.me and mercedes.mj are pointers to std::string's, therefore you should use the * operator. Here is how the whole corrected function should look:

bool operator ==(cars& any, cars& mercedes) {
   int k;
   for (k = 0; k < mercedes.mj->length(); k++) {
      return ((*any.me)[k] == (*mercedes.mj)[k]);
   }
}

However, I get this horrible feeling that both of those members shouldn't have been pointers in the first place, so all of this may have been useless. :icon_eek:

I will be honest, I can't be bothered going through any more :icon_lol: So my advice to you, is read some tutorials on pointers and data types, then have another go at it. But here, I went to the trouble of finding them for you.. Pointer Tutorial - Data Types Tutorial

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.