Wednesday, April 7, 2021

simple program (OOP) (60)

#include<iostream>

#include<string>

using namespace std;

class Train

{

private:

string name,source,distination;

int number,journeydata,capacity;

public:

Train()

{

name='0';

source='0';

distination='0';

number='0';

journeydata='0';

capacity='0';

}

void input_train_data();

void display();

};

void Train::input_train_data()

{

cout<<"kindly enter the name of the train:";

cin>>name;

cout<<endl;

cout<<"kindly enter the source of the train:";

cin>>source;

cout<<endl;

cout<<"kindly enter the distination of the train:";

cin>>distination;

cout<<endl;

cout<<"kindly enter the number of the train:";

cin>>number;

cout<<endl;

cout<<"kindly enter the journey date of the train:";

cin>>journeydata;

cout<<endl;

cout<<"kindly enter the capacity of passenger in the train:";

cin>>capacity;

cout<<endl;

}

void Train::display()

{

system("cls");

cout<<"//////////////////All information//////////////////////"<<endl;

cout<<"the name of the train is:"<<name<<endl;

cout<<"the number of the train is:"<<number<<endl;

cout<<"the distination of the train is:"<<distination<<endl;

cout<<"the journey date of the train is:"<<journeydata<<endl;

cout<<"the capacity of the train is:"<<capacity<<endl;

cout<<"the source of the train is:"<<source<<endl;

}

int main()

{

Train obj;

obj.input_train_data();

obj.display();

 

No comments:

Post a Comment