Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
A car salesman wants to implement an information system that stores details about the car he sells,i.e the make of the car, year the model was released, the price and the mileage on the car. create a c++ class car that has:
All the data members included the details indicated above

A constructor that initializes each data member with the values indicated below

Make:default
Year:2005
Price:500,000
Mileage:10,000

A setDetails function that captures the above details from a user for a car object

A getDetails function that prints out all the details for a car object
Posted

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!
 
Share this answer
 
Comments
zlogdan 5-Jul-13 8:37am    
5 stars!
Class clsnme
{
public int year, price,mileage;

//Constructor

class clsnme
{
int year=2005,price=50000,mileage=10000;
}

//Set Details:

public void setdetails
{
cout<<"Enter the Year:";
cin>>year;
cout<<"\nEnter the Price:";
cin>>price;
cout<<"\nEnter the Mileage:";
cin>>mileage;
}

//Get Details

Public void getdetails
{
cout<<"Year:<<year<<"\n";
cout<<"Price:<<"\n";
cout<<"Mileage:<<"\n";
}

}


Call these functions in main wherever you want. If u Print without calling setdetails it will print values in constructor. Or otherwise it will get values from user (if setdetails() called). Hope it will work
 
Share this answer
 
Comments
Richard MacCutchan 3-Jul-13 7:02am    
It really does not help people to do their homework for them.
KuttiSankar 3-Jul-13 7:05am    
Yes I understand, But it is just small help to write code for him.
KuttiSankar 3-Jul-13 8:27am    
what is the meaning of downvoted? and is that my code is wrong and why it is downvoted i don't know
Usman Hunjra 4-Jul-13 4:17am    
AGREE .. w i t h .. Richard MacCutchan && OriginalGriff
zlogdan 5-Jul-13 8:40am    
Posting such questions leads to people being awarded for doing the job someone else should have done, either for learning or for profit. I suspect some people make simple questions to "friends" to easily answer them. Just like, hey "what is int i = 0; ?" I downvoted your solution as well.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900