#include<iostream.h>
#include<fstream.h>
#include<string.h>
class database{
public:
virtual double store_data(void);
virtual void save(ofstream &file);
virtual double GetPassingMark(int pass);
virtual void display(void);
virtual void edit(void);
protected:
void data(void);
//database(){cout<<"constructing";}
//~database(){cout<<"destructing";}
};
double database::store_data(void)
{
char code[100];
double totalmark,laboraty,exam,assignment,sum_assignment;
int i,no_of_parts,a,pass;
totalmark=0;
for(i=0;i<7;i++)
{
cout<<"=======================================================\n";
cout<<"1.enter the subject code"<<i+1<<"\n";
cin>>code;
cout<<"2.Enter no of assigments\n:";
cin>>no_of_parts;
sum_assignment=0;
for(a=0;a<no_of_parts;a++)
{
cout<<"assignment"<<a+1<<":";
cin>>assignment;
sum_assignment=sum_assignment+assignment;
}
cout<<"4.labotary\n";
cin>>laboraty;
cout<<"5.exam\n";
cin>>exam;
totalmark=sum_assignment+laboraty+exam;
GetPassingMark(totalmark);
cout<<"=======================================================\n";
}
}
void database::save(ofstream &file)
{
int index,assignment,i,no_of_parts,a;
char code[100];
double laboraty,exam,sum_assignment;
for(i=0;i<7;i++)
{
file<<"Subject code"<<code<<endl;
file<<"no of assignments"<<no_of_parts<<endl;
file<<"total marks"<<sum_assignment<<endl;
for (a=0;a<no_of_parts;a++)
{
save(file);
}
}
}
double database::GetPassingMark(int pass)
{
cout<<"Your total mark is:"<<pass;
if(pass>=40)
{
cout<<"\nYou have already passed the subject.....oh yeah\n";
}
else
{
cout<<"\nMarks required to pass="<<(40-pass)<<endl;
}
}
void database::display(void)
{
}
void database::edit(void)
{
}
int main(void)
{
database work;
ofstream file;
int option;
cout<<"Please make your selection\n";
cout<<"1.insert data\n";
cout<<"2.edit the stored data\n";
cout<<"3.display the stored result\n";
cout<<"4.exit\n";
cin>>option;
switch(option)
{
case 1:work.store_data();
file.open("D:\\A.txt",ios::app);
work.save(file);
file.close();
break;
default: break;
case 2:;
//case 3:break;
//case 4:break;
}
return(0);
}
karthz85 -2 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.