Skip to main content

C++ Projects (MAKING DMC )

c++ project of dmc


#include<iostream>
#include<fstream>
#include<iomanip>
#include<conio.h>
#include<windows.h>
using namespace std;
class student
{
protected :
char  name[50];
int roll;
char board[50];


};
class dmc:public student
{
protected :
float per;
int phy;
int maths;
int cs;
int english;

public :
void getdata()
{
cout<<"ENTER NAME : ";
cin>>name;
cout<<"ENTER ROLL : ";
cin>>roll;
cout<<"PHYSIC MARK : "<<endl;
cin>>phy;
cout<<"MATHS MARKS :"<<endl;
cin>>maths;
cout<<"ENTER CS MARKS :"<<endl;
cin>>cs;
cout<<"ENTER ENGLISH MARKS : "<<endl;
cin>>english;
  
}
float calculate()
{
per=(((phy+maths+cs+english)*(100))/400);
return per;
}
double add()
{
double total;
total=phy+maths+cs+english;
return total;
}
void show_all_data()
{
cout<<" \nNAME    : "<<name<<endl;
cout<<" ROLL    : "<<roll<<endl;
cout<<" PHYS    : "<<phy<<endl;
cout<<" MATHS   : "<<maths<<endl;
cout<<" CS      : "<<cs<<endl;
cout<<" ENGLISH : "<<english<<endl;
cout<<"TOTAL MARKS :"<<add()<<endl;
            cout<<"PERCENTAGE :"<<calculate()<<endl;
            
}
bool search(int x)
{
if(x==roll)
{
return true;
}
else
{
return false;
}
}
void modify()
{
int x;
cout<<"1 NAME    : "<<endl;
cout<<"2 ROLL    : "<<endl;
cout<<"3 PHYS    : "<<endl;
cout<<"4 MATHS   : "<<endl;
cout<<"5 CS      : "<<endl;
cout<<"6 ENGLISH : "<<endl;
cout<<"Enter your option (1-6) : ";
cin>>x;
if(x==1)
{
cout<<"Name: ";
cin>>name;
}
if(x==2)
{
cout<<"ROLL    : ";
cin>>roll;
}
if(x==3)
{
cout<<"PHYS    : ";
cin>>phy;
}
if(x==4)
{
cout<<"MATHS   : ";
cin>>maths;
}
if(x==5)
{
cout<<"CS      : ";
cin>>cs;
}
if(x==6)
{
cout<<"ENGLISH : ";
cin>>english;
}



}
void dmc1()
{
cout<<"*******************DMC**********************"<<endl;
cout<<"  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  "<<endl;                
cout<<"*            ======================================================      *"<<endl;
cout<<"*  NAME : |         SUBS     |                                           *"<<endl;
cout<<"*         |                  |                                           *"<<endl;
cout<<"* --------|         ENGLISH  | "<<english;cout<<"\t\t\t\t\t *"<<endl;
cout<<"* "; cout<<name<<"\t\t                                                         * "<<endl;
cout<<"*         |         CS       | "<<cs<<"    \t      \t     \t                 *"<<endl;
cout<<"* ------- |                  |                                           *"<<endl;
cout<<"*  ROLL  :|         MATHS    | "<<maths;cout<<"\t\t                         *"<<endl;
cout<<"*         |                  |                                           *"<<endl;
cout<<"*-------- |         PHY      | "<<phy;cout<<"       PERCENTAGE :\t\t         *"<<endl;
cout<<"* ";cout<<roll<<"\t\t                                                         *"<<endl;
cout<<"*         |  TOTAL MARTKS    |  ";cout<<add()<<"  \t      "<<calculate()<<endl;
cout<<"*         |                                                              *"<<endl;
cout<<"*            =====================================================       *"<<endl;
cout<<"                                                                     "<<endl;
            cout<<"    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * "<<endl;
}
void dis_record()
{

cout<<name<<"\t"<<roll<<"\t"<<phy<<"\t"<<cs<<"\t"<<maths<<"\t"<<english<<"\t"<<add()<<"\t"<<calculate()<<endl;
}
};
 void intro()
{
cout<<"\n\n\n\t\t  STUDENT";
cout<<"\n\n\t\tREPORT CARD";
cout<<"\n\n\t\t  PROJECT";
cout<<"\n\n\n\tMADE BY : IMRAN AND HUMMAD";
cout<<"\n\n\t\t\tUNIVERCITY : CITY UNIVERCITY "<<endl;
getch();
}


int main()
{
dmc dm[50];  
bool flag; 
int g;// for goto entry menue
int gg;// goto to main menu 
fstream file,var;
char del;
char ans; // for more data
intro();
int op;// for main menu;
int op2; // for report menu;
int op1;// for entery menu;
int n=0;//for check if data ==0;
int a,id;
while(1)
{

      
        gg:
        cout<<"\n*********************************"<<endl;
        cout<<"\n\nMAIN MENU :"<<endl;
    cout<<"[01] for result menu :\n\n"<<endl;
    cout<<"[02] for entry menu :\n\n"<<endl;
    cout<<"[03] for exit       :"<<endl;
    cin>>op;
   if(op==1)   
   {
    cout<<"[result all menu]"<<endl;
    cout<<"[1] DMC "<<endl;
    cout<<"[2] for record "<<endl;
    cout<<"enter choice :"<<endl;
    cin>>op1;
    if(op1==1)
    {
    var.open("index.txt",ios::in);
      if(var)
      {
      var>>n;
      var.close();
     
      }
       
        file.open("record.dat",ios::in);
         for(int i=0;i<n;i++)
        {
        file.read((char *)&(dm[i]),sizeof((dm[i])));
   
     
        }
         file.close();
       
       
         while(1)
         {
          cout<<"\nEnter 1 to continue or 2 to back: ";
 cin>>a;
 if(a==1)
 {
  cout<<"Enter Your Rollno: ";
 cin>>id;
  for(int i=0;i<n;i++)
  {
  flag=dm[i].search(id);
  if(flag==true)
  {
  cout<<"\nRecord found\n"<<endl;
  dm[i].dmc1();
  flag==false;
  }
  }
 }
 
 if(a==2)
 {
  break;
 } 
         }
   
   
    }
    if(op1==2)
    {
    cout<<"****************STUDENT DMC********************************************"<<endl;
cout<<"NAME\tROLLNUM\tPHY\tCS\tMATHS\tENG\t TOTAL \t PER%"<<endl;
    var.open("index.txt",ios::in);
      if(var)
      {
      var>>n;
      var.close();
     
      }
    file.open("record.dat",ios::in);
         for(int i=0;i<n;i++)
        {
        file.read((char *)&(dm[i]),sizeof((dm[i])));
     dm[i].dis_record();
     
        }
         file.close();  
   
   
   
    }
   
   }
   
   
     else if(op==2)
   {  //  STARTED HERE ENTRY 
   
    char oop; // for choices 
    g :
    cout<<"ENTRY MENU :\n\n"<<endl;
    cout<<"[1] for enrty :"<<endl;
    cout<<"[2] for dislapy all record simple :"<<endl;
    cout<<"[3] for search just result  :"<<endl;
   
    cout<<"[4] for delete :"<<endl;
    cout<<"[5] for modify :"<<endl;
cout<<"[6] for back menu\n\n\n :"<<endl; 

cout<<" your choices ==> : "<<endl;
cin>>oop;
if(oop=='1')
{   // STARTED HERE 1
do
      {
      var.open("index.txt",ios::in);
      if(var)
      {
      var>>n;
      var.close();
     
      }
  dm[n].getdata();
  file.open("record.dat",ios::out|ios::app);
  file.write((char *)&dm[n],sizeof(dmc));
  file.close();
  n=n+1;
  var.open("index.txt",ios::out);
  var<<n<<endl;
  var.close();
  cout<<"<> : DO YOU WANT TO ADD MORE RECORD (y/n) : <>"<<endl;
       cin>>ans;
     }
 while(ans=='y'||ans=='Y');
if('n')
{
goto g;
}
}  // ENDED HERE 1 


else if(oop=='2')
    {  //STARTED HERE 2    
var.open("index.txt",ios::in);
      if(var)
      {
      var>>n;
      var.close();
     
      }
    file.open("record.dat",ios::in);
         for(int i=0;i<n;i++)
        {
        file.read((char *)&(dm[i]),sizeof((dm[i])));
     dm[i].show_all_data();
     
        }
         file.close();
   
        }// END HERE 2
        
        else if(oop=='3')
        {// STARTED HERE 3
        // searching 
        var.open("index.txt",ios::in);
      if(var)
      {
      var>>n;
      var.close();
     
      }
       
        file.open("record.dat",ios::in);
         for(int i=0;i<n;i++)
        {
        file.read((char *)&(dm[i]),sizeof((dm[i])));
   
     
        }
         file.close();
       
       
         while(1)
         {
          cout<<"\nEnter 1 to continue or 2 to back: ";
 cin>>a;
 if(a==1)
 {
  cout<<"Enter Your Rollno: ";
 cin>>id;
  for(int i=0;i<n;i++)
  {
  flag=dm[i].search(id);
  if(flag==true)
  {
  cout<<"\nRecord found\n"<<endl;
  dm[i].show_all_data();
  flag==false;
  }
  }
 }
 
 if(a==2)
 {
  break;
 } 
         }
 
       
       
        } // ENDED HERE 3
        
         else if(oop=='4')
        {// STARTED HERE 4
while(1) 
{

 
var.open("index.txt",ios::in);
      if(var)
      {
      var>>n;
      var.close();
     
      }
       
        file.open("record.dat",ios::in);
         for(int i=0;i<n;i++)
        {
        file.read((char *)&(dm[i]),sizeof((dm[i])));
   
     
        }
         file.close();
  cout<<"\nEnter 1 to continue or 2 to back: ";
cin>>a;
if(a==1)
{

         cout<<"Enter the roll no: ";
         cin>>id;
 for(int i=0;i<n;i++)
 {
flag=dm[i].search(id);
if(flag==true)
{
dm[i].show_all_data();
cout<<"Enter (y/n) to delete record: ";
cin>>del;
if(del=='y')
{
remove("record.dat");

for(int j=i;j<n;j++)
{
dm[i]=dm[i+1];
i++;
}
n=n-1;

var.open("index.txt",ios::out);
var<<n<<endl;
var.close();
file.open("record.dat",ios::out|ios::app);
for(int i=0;i<n;i++)
{
file.write((char *)&(dm[i]),sizeof((dm[i])));
}
file.close();
cout<<"\nRecord Deleted\n"<<endl;
}
if(del=='n')
{
continue;
}

}
 }


}
if(a==2)
{
break;
}
}
        } // ENDED HERE 4
         else if(oop=='5')
        {// STARTED HERE 5
        while(1)
        {
        var.open("index.txt",ios::in);
      if(var)
      {
      var>>n;
      var.close();
     
      }
       
        file.open("record.dat",ios::in);
         for(int i=0;i<n;i++)
        {
        file.read((char *)&(dm[i]),sizeof((dm[i])));
   
     
        }
         file.close();
        cout<<"Enter 1 to continue or 2 to back: ";
        cin>>a;
        if(a==1)
        {
        cout<<"Enter roll no: ";
        cin>>id;
        for(int i=0;i<n;i++)
        {
        flag=dm[i].search(id);
        if(flag==true)
        {
        dm[i].modify();
        remove("record.dat");
        file.open("record.dat",ios::out|ios::app);
        for(int i=0;i<n;i++)
        {
        file.write((char *)&(dm[i]),sizeof((dm[i])));
   
     
        }
        file.close();
        cout<<"\nRecord Modified\n"<<endl;
        flag=false;
        }
        }
        }
       
        if(a==2)
        {
        break;
        }
        }
       
        } // ENDED HERE 5
         else if(oop=='6')
        {// STARTED HERE 6
        goto gg;
        } // ENDED HERE 6
        


 
    }// ENDED HERE ENTRY 


if(op==3)
{
exit(0);
}

}// while loop
}

Comments

Popular posts from this blog

C++ project of school mangment system

            C++ SIMPLE PROJECT FOR STORYING RECORDS OF STUDENTS    POST COMMENT FOR ANY ERROR OR IF YOU HAVE ANY PROBLEM WITH THE                                                           CODE  #include<iostream>  #include<windows.h> using namespace std; int main() { string name[3]; int id[3] ; int count=0; int z; int y; int ch; int k; int roll; int c; int dd; char yy; cout<<"*************************WELLCOME TO DATABASE         SYSTM*********************"<<endl; while(1) { cout<<"\t\tpress 1 for entry "<<endl; cout<<"\t\tpress 2 for full data display "<<endl;          cout<<"\t\tpress 3 changing :  "<<endl;           c...