Print Friendly and PDF
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<fstream.h>
class student
{
public:
int r_no , sec ,clas;
char name[20];
student()
{
r_no = 1;
clas = 2;
sec = 3;
}
void get (void)
{ 
cout<<"enter the roll no"<<endl;
cin>>r_no; 
cout<<"enter the class"<<endl;
cin>>clas;
cout<<"enter the section number"<<endl;
cin>>sec;
cout<<"enter the name"<<endl;
gets(name);
}
void show()
{
cout<<"Roll No"<<r_no<<endl<<"Name"<<name<<endl<<"Class"<<clas<<endl<<"Sec"<<sec<<endl;
}
};
class exam : public student
{
public:
int oop, db, net, bf;
float per, t_marks;
char stats;
char w[2];
exam()
{
oop=23;
net=43;
db=43;
bf=23;
}
void showw(void);
void marks (void)
{
cout<<"press Q for quiz ,M for mid , F for final examz"<<endl;
gets(w);
int a=0;
while (a<=3)
{
cout<<"enter the oops marks";
cin>>oop;
if (oop <= 50)
{ 
break;
}
else
cout<<"invalid";
a++;
}
while (a<=3)
{
cout<<endl<<"enter the database marks";
cin>>db;
if (db <= 50)
{
break;
}
else
cout<<"invalid";
a++;
}
while (a<=3)
{
cout<<endl<<"enter the net marks";
cin>>net;
if (net <= 50)
{
break;
}
else
cout<<"invalid";
a++;
}
while (a<=3)
{
cout<<endl<<"enter the business finance marks";
cin>>bf;
if (bf <= 50)
{
break;
}
else
cout<<"invalid";
a++;}
}
void sum(void)
{
t_marks= oop + db + net +bf;
per= (t_marks/200)*100;
cout<<"total marks are:"<<t_marks<<endl;
cout<<"percentage is : "<< per <<endl;
}
void status (void)
{
if (t_marks >= 75)
cout<<endl<<"pass"<<endl;
else
cout<<endl<<"fail"<<endl;
}
void display()
{
cout<<"OOP MARKS"<<oop<<endl<<"Database"<<db<<endl<<"Bussiness Finance"<<bf<<endl<<"Networking"<<net<<endl;
}
}; 
void main (void)
{ 
exam obj;
// {
//obj[a].get();
//obj[a].marks();
//obj[a].sum();
//obj[a].status();
//}
// for( int z=0;z<=2;z++)
// {
//obj[z].show();
//} //cout<<"Enter the Roll No for Searching";
//cin>>r;
//for(int s=0;s<=2;s++)
//{
//if(r==obj[s].r_no)
//{
//cout<<"Name"<<obj[s].name<<endl;
//break;
//}
//}
int w;
char ch;
Main:cout<<"press 1 to enter values"<<endl<<"2 to display"<<endl<<"3 for searching by roll number"<<endl<<"4 for searching by class"<<endl;
cin>>w;
switch(w)
{
case 1:
{
ofstream one("D:\\oops.dat",ios::out|ios::app);
do
 {
obj.get();
obj.marks();
obj.sum();
obj.status();
one.write((char*)&obj,sizeof(obj));
}
while(ch=='n'||ch=='y');
choice: cout<<"Do you wish to continue[Press 'y' to continue or 'n' to exit menu]: ";
cin>>ch;
if (ch == 'y')
{
obj.get();
obj.marks();
obj.sum();
obj.status();
one.write((char*)&obj,sizeof(obj));
goto choice;
}
else
{
 one.close(); 
goto Main;}
} 
break;
case 2: 
{
ofstream one("D:\\oops.dat",ios::out|ios::app);
{
obj.show();
obj.display();
one.write((char*)&obj,sizeof(obj));
}
goto Main;
} 
break;
case 3: 
{ 
int r;
cout<<"Enter the Roll No for Searching";
cin>>r;
if(r==obj.r_no)
{
cout<<endl<<"Name"<<obj.name<<endl;
cout<<endl<<"total marks"<<obj.t_marks<<endl;
}
goto Main;
}
break;
case 4: 
 {
int r;
cout <<"enter the class to search";
cin>>r;
if(r==obj.clas)
{
cout<<"name"<<obj.name<<endl;
cout<<"roll no"<<obj.r_no<<endl;
cout<<"total marks"<<obj.t_marks<<endl;
}
goto Main;
}
break;
default:
cout<<"Invalid Input";
}
}
zubairsaif

Zubair saif

A passionate writer who loves to write on new technology and programming

Post A Comment:

1 comments: