A very basic C++ program using OOP concepts to get and show car details from user..
#include
#include
#include
using namespace std;
class car{
private:
char name[30];
char color[20];
double year;
long price;
public:
car(){
cout << "\n\t Welcome to CAR SHOWROOM! \n";
}
void getcar(){
cout << "\n\t Enter car name:";
gets_s(name);
cout << "\n\t Enter color:";
cin >> color;
cout << "\n\t Enter year make:";
cin >> year;
cout << "\n\t Enter car price:";
cin >> price;
}
void showcar(){
cout << "\n\t Car name:" << name;
cout << "\n\t Car year:" << year;
cout << "\n\t Car price:" << price;
cout << "\n\t Car color:" << color;
cout << endl;
}
};
void main() {
car c;
c.getcar();
c.showcar();
system("pause");
}
Leave a Reply