MENU
Question -

Define a class Applicant in C++ with the following description:
Private members
тАв┬а A data member ANo(Admission Number) of type long
тАв┬а A data member Name of type String
тАв┬а data member Agg(Aggregate Marks) of type float
тАв┬а A data member Grade of type char
тАв┬а A member function GradeMe() to assign the grades as per the aggregate obtained by the candidate.
тАв┬а Score range and the respective remarks are shown as follow:
Aggregate┬а ┬а ┬а ┬а ┬а ┬а ┬а ┬а ┬а ┬аGrade
>=80┬а ┬а ┬а ┬а ┬а ┬а ┬а ┬а ┬а ┬а ┬а ┬а ┬а ┬а ┬а ┬аA
less than 80 and > = 65┬а ┬а ┬аB
less than 65 and > = 50┬а ┬а ┬аC
less than 50┬а ┬а ┬а ┬а ┬а ┬а ┬а ┬а ┬а ┬а ┬а ┬а ┬аD
Public members
тАв A function ENTER( ) to allow user to enter values for ANo, Names, Aggregate and call function GradeMe () to assign grade.
тАв A function RESULT( ) to allow user to view the content of all data members.┬а



Answer -

class Applicant
┬а{
┬аlong ANo;┬а
char Name[40];┬а
float Agg;┬а
char Grade;
┬аvoid GradeMe ( )┬а ┬а [1]
┬а{
┬аif (Agg>80)
┬аGrade='A';
┬аif (Agg<80 && Agg>=65)
┬аGrade='B';
┬аif (Agg<65 && Agg>=50)
┬аGrade='C'; if(Agg<50)
┬аGrade='D';
┬а}
┬аpublic:┬а
void Enter ( )
{
┬аcout<<''Enter the values for Ano, Name, Agg" ;┬а
cin>>ANo;┬а
gets(Name);
┬аcin>>Agg;┬а ┬а [1]
┬аGradeMe( );
┬а}
┬аvoid Result( )
┬а{
┬аcout<
┬аputs(Name); puts(Grade);
┬а}
┬а};┬а ┬а [1]

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
×