Page 127 - C++
P. 127
cout<<” enter bus number “;
cin>>busno;
cout<<” enter source station “;
gets(from);
cout<<” enter ending station “;
gets(to);
cout<<” enter type of bus “;
cin>>type;
cout<<” enter distance travelled “;
cin>>distance;
calcfare();
}
void BUS::calcfare()
{
if (type ==’O’)
fare=distance * 15;
else if(type==’E’)
fare=distance * 20;
else if(type=’L’)
fare=distance * 24;
}
void BUS::show()
{
cout<<” bus number “<<busno;
cout<<”\n source station “;
puts(from);
cout<<”\n ending station “;
puts(to);
cout<<”\n type of bus “<<type;
cout<<” \n distance travelled “<<distance;
cout<<”\n fare is “<<fare;
d) Answer the questions (i) to (iv) based on the following. 4
class personal
{ int clas,rno;
char sec;
protected:
char name[20];
public:
personal();
void penter();
void pdisplay();
};
XII / Comp. Sc. Page 6 of 17