Professional Documents
Culture Documents
Prog 8
Prog 8
Source code:
#include<iostream.h>
#include<conio.h>
class SCHOOL
{char sname[25];
int sfees;
public:
void SINPUT()
{cout<<"\n\tEnter the school name:";
cin>>sname;
cout<<"\tEnter the school fees:";
cin>>sfees;
}
void SOUTPUT()
{cout<<sname<<"\t"<<sfees<<"\t\t";
}
int Schoolfees()
{
return sfees;
}
};
class BUS
{int bno,bfees;
public:
void BINPUT()
{cout<<"\tEnter the bus number:";
cin>>bno;
cout<<"\tEnter the bus fees:";
cin>>bfees;
}
void BOUTPUT()
{cout<<bno<<"\t"<<bfees<<"\t";
}
int Busfees()
{
return bfees;
}
};
protected:
int calc()
{
return(Schoolfees()+Busfees());
}
public:
void IN()
{cout<<"\n\tEnter the student's name:";
cin>>name;
SINPUT();
BINPUT();
totfee=calc();
}
void OUT()
{cout<<name<<"\t\t";
SOUTPUT()
BOUTPUT();
cout<<totfee<<endl;
}
}S[10];
int main()
{int n;
cout<<"\nEnter the number of students whose details are to be
cin>>n;
for(int i=0;i<n;++i)
S[i].IN();
cout<<"\n\nStudent name\tSchool\tSchool fee\tBus no\tBus fee\tTotal fee\n";
for(int i=0;i<n;++i)
entered:";
S[i].OUT();
getch();
return 0;
}
OUTPUT:
Student name
Afrah
ENS
840
Maria
DPS
1500
34
300
1800
750
45
150
900
Munaiza
IES
11
1040