Define a class TEST in C++ with following description:Private MembersTestCode of type integerDescription of type stringNoCandidate of type integerCenterReqd (number of centers required) of type integerA member function CALCNTR() to calculate and return the number of centers as(NoCandidates/100+1)Public Members - A function SCHEDULE() to allow user to enter values for TestCode, Description, NoCandidate & call function CALCNTR() to calculate the number of Centres- A function DISPTEST() to allow user to view the content of all the data members
#include <iostream>
using namespace std;
class Test{
private:
int MembersTestCode;
string Description;
int NoCandidate;
int CenterReqd;
int CALCNTR(){
return (NoCandidate/100+1);
}
public:
void SCHEDULE(){
cout<<"\nEnter test code: ";
cin>>MembersTestCode;
cout<<"\nEnter description: ";
cin>>Description;
cout<<"\nEnter No of Candidates: ";
cin>>NoCandidate;
cout<<"\nEnter center rad: ";
cin>>CenterReqd;
CALCNTR();
}
void DISPTEST(){
cout<<"\nTest code: "<<MembersTestCode;
cout<<"\nDescription: "<<Description;
cout<<"\nNo of Candidates: "<<NoCandidate;
cout<<"\nCenter rad: "<<CenterReqd;
cout<<"\nCenter:"<<CALCNTR();
}
};
int main()
{
Test t;
t.SCHEDULE();
t.DISPTEST();
return 0;
}
Comments
Leave a comment