#include<iostream.h>
#include<fstream.h>
#include<string.h>
#include<stdio.h>
class database{
			public:
		    virtual double store_data(void);
			virtual double GetPassingMark(int pass);
			virtual void display(void);
			virtual void edit(void);
			protected:
			void data(void);

//database()
//~database()
	   	   	   
};

double database::store_data(void)
{
   char code[100];
   double totalmark,laboratory,exam,assignment,sum_assignment;
   int i,no_of_parts,a,pass;
   totalmark=0;
	ofstream display("D:\\record system.txt");
     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>>laboratory;
	 cout<<"5.exam\n";

	 cin>>exam;
	 totalmark=sum_assignment+laboratory+exam;
	 GetPassingMark(totalmark);
	 display<<code<<"\n"<<sum_assignment<<"\n"<<laboratory<<"\n"<<exam<<endl;
	 cout<<"=======================================================\n";
	 
	 
	 }
}


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)
{
	ifstream file1;
	char str[101];
	char str2[101];
	char code[100];
	char code1[100];
	bool iscodeFound;
	iscodeFound = false;
	file1.open("D:\\record system.txt",ios::in);
	cout<<"Enter subject code:";
	cin>>code1;
	sprintf(str2,"code:%s",code1);
	while(!file1.eof())
	{
		file1.getline(str,100);
		if(strcmp(str,str2)==0)
		{
			
			iscodeFound=true;
			break;	  	  	  
		}
	}
	if(iscodeFound)
	{
		while(!file1.eof())
		{
			file1.getline(str,100);
			if(strncmp(str,"code",strlen("code"))!=0)
			cout<<str<<endl;
			else
			break;
		}
	}
	else
	{
		cout<<"Subject not Found";
	}
	file1.close();
}	 	 
	
	


void database::edit(void)
{
	
}






int main(void)
{
  
  database work[25];
  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[0].store_data();

				 break;
		default: break;
		case 2:;
		
		case 3:
		work[0].display();
		break;
		
		//case 4:break;
		
	}
return(0);
}

Edited 6 Years Ago by Nick Evan: Added code-tags

Comments
code-tags. Use them.
void database::display(void)
{
	ifstream file1;
	char str[101];
	char str2[101];
	char code[100];
	char code1[100];
	bool iscodeFound;
	iscodeFound = false;
	file1.open("D:\\record system.txt",ios::in);
	cout<<"Enter subject code:";
	cin>>code1;
	sprintf(str2,"code:%s",code1);
	while(!file1.eof())
	{
		file1.getline(str,100);
		if(strcmp(str,str2)==0)
		{
			
			iscodeFound=true;
			break;	  	  	  
		}
	}
	if(iscodeFound)
	{
		while(!file1.eof())
		{
			file1.getline(str,100);
			if(strncmp(str,"code",strlen("code"))!=0)
			cout<<str<<endl;
			else
			break;
		}
	}
	else
	{
		cout<<"Subject not Found";
	}
	file1.close();
}

Edited 6 Years Ago by Nick Evan: Added code-tags (again)

Read this and this and then repost. I'm getting sick of having to add code-tags to each and every one of your posts :icon_frown:

Edited 6 Years Ago by Nick Evan: n/a

This article has been dead for over six months. Start a new discussion instead.