Create a base class Student(Roll_No, Name) which derives two classes Academic_Marks(Mark1, Mark2, Mark3) and Extra_Activities_Marks(Marks). Class Result(Total_Marks, Grade) inherits both Academic_Marks and Extra_Activities_Marks classes. (Use Virtual Base Class) Write a C++ menu driven program to perform the following functions: i. Build a master table ii. Calculate Total_marks and grade
//Note: If you are not using Borland or Turbo C then add the following line after header files :
//using namespace std;
#include<conio.h>
#include<iostream.h>
class stu
{
public:
int rno;
char name[10]; //name=student name , rno= roll no
void accept()
{
cout<<"Enter Roll no: ";
cin>>rno;
cout<<"\nEnter student name: ";
cin>>name;
}
};
class ac: public stu // inherit class ac
{
protected:
int m1,m2,m3; //m1=marks1 , m2=marks2 , m3=marks3
public:
void acc()
{
cout<<"Enter marks in 1 subject: ";
cin>>m1;
cout<<"Enter marks in 2 subject: ";
cin>>m2;
cout<<"Enter marks in 3 subject: ";
cin>>m3;
}
};
class ec: public ac // inherit class ec
{
protected:
int m4; //m4=marks4
public:
void acce()
{
cout<<"Enter extra curricular activities: ";
cin>>m4;
}
};
class result: public ec // inherit class result
{
public:
int m;
void cal()
{
m=m1+m2+m3+m4; //calculating marks
cout<<"Total Marks: "<<m<<endl<<"Grade : ";
if(m>75)
cout<<"A grade"<<endl;
else if(m>65)
cout<<"B grade"<<endl;
else if(m>45)
cout<<"C grade"<<endl;
else if(m>35)
cout<<"pass"<<endl;
else if(m>0)
cout<<"Fail"<<endl;
}
};
void main()
{
int ch;
result s1; //instance of class result
cout<<endl;
do
{
cout<<"\n1.build a report"<<endl;
cout<<"2.calculate marks and grade: "<<endl;
cout<<"3.Exit: "<<endl;
cout<<"\nchoose one: ";
cin>>ch;
cout<<endl;
switch(ch)
{
case 1:
s1.accept();
s1.acc();
s1.acce();break;
case 2:
s1.cal(); break;
}
}while(ch!=3);
}
-
Next Create a base class Account (Acc_Holder_Name, Acc_Holder_Contact_No). Derive a two classes as Saving_Account(S_Acc_No., Balance) and Current_Account( C_Acc_No., Balance) from Account. Write a C++ menu driven program to perform following functions : i. Accept the details for ‘n’ account holders. ii. Display the details of ‘n’ account holders by adding interest amount where interest rate for Saving account is 5% of balance and interest rate for Current account is 1.5% of balance.
-
Previous Write a C++ program to create a class Date which contains three data members as dd, mm, yyyy. Create and initialize the object by using parameterized constructor and display date in dd-mon-yyyy format. (Input: 19-12-2014 Output: 19-Dec-2014) Perform validation for month.
0 Comments