#include<iostream.h>
#include<conio.h>
class vehicle
{
protected:
char regno[10];
int model;
public:
void read()
{
cout<<"\nEnter the Register Number:";
cin>>regno;
cout<<"\nEnter the model number:";
cin>>model;
}
void print()
{
cout<<"\n\t\tOUTPUT"<<endl;
cout<<"\nRegister No:"<<regno<<endl;
}
};
class two_wheeler : public vehicle
{
protected:
int no_gear,power;
public:
void read1()
{
read();
cout<<"\nEnter the no.of gear:";
cin>>no_gear;
cout<<"\nEnter the no.of power:";
cin>>power;
}
void print1()
{
print();
cout<<"\n\tno.of gears:"<<no_gear<<"\n";
cout<<"\n\tpower:"<<power<<"\n";
}
};
class scooter : public two_wheeler
{
protected:
char mfr[25],owner[20];
public:
void read2()
{
read1();
cout<<"\nEnter the manufacturer:";
cin>>mfr;
cout<<"\nEnter the owner:";
cin>>owner;
}
void print2()
{
print1();
cout<<"\n\t Manufacturer:"<<mfr;
cout<<"\n\t owner:"<<owner;
}
};
class four_wheeler : public vehicle
{
protected:
char fuel[15];
int no_cylinder;
public:
void read3()
{
read();
cout<<"\nEnter the fuel:";
cin>>fuel;
cout<<"\nEnter the no.of cylinder:";
cin>>no_cylinder;
}
void print3()
{
print();
cout<<"\n\t Fuel:"<<fuel<<endl;
cout<<"\n\tno.ofcylinders:"<<no_cylinder;
}
};
class car : public four_wheeler
{
protected:
char name[25];
char owner[25];
public:
void read4()
{
read3();
cout<<"\n\tEnter the car name:";
cin>>name;
cout<<"\n\tEnter the owner name:";
cin>>owner;
}
void print4()
{
print3();
cout<<"\n\tCar Name:"<<name;
cout<<"\n\t Owner:"<<owner;
}
};
void main()
{
clrscr();
scooter s;
car c;
cout<<"\nVEHICLE TWO WHEELER\n";
s.read2();
s.print2();
cout<<"\nVEHICLE FOUR WHEELER\n";
c.read4();
c.print4();
getch();
}
Comments
Post a Comment