Monday, 28 January 2013

final project 1st semester


#include<iostream.h>             // raja muhammad zeeshan ashraf
#include<fstream.h>              // bs(cs) 1st B evening
#include<conio.h>                                        
#include<string>
#include<cstdlib>
using namespace std;
struct shan
{
int MISID;
char name[40];
char father_name[40];
char department[40];
char registration[30];
char title_of_degree[30];
char semester[5];
char shift[10];
char sub1[10];
char sub1_code[10];
int sub1_credit_hours;
int sub1_marks;
int sub1_obt_marks;
char sub2[10];
char sub2_code[10];
int sub2_credit_hours;
int sub2_marks;
int sub2_obt_marks;
char sub3[10];
char sub3_code[10];
int sub3_credit_hours;
int sub3_marks;
int sub3_obt_marks;
char sub4[10];
char sub4_code[10];
int sub4_credit_hours;
int sub4_marks;
int sub4_obt_marks;
char sub5[10];
char sub5_code[10];
int sub5_credit_hours;
int sub5_marks;
int sub5_obt_marks;
char sub6[10];
char sub6_code[10];
int sub6_credit_hours;
int sub6_marks;
int sub6_obt_marks;
};

void create_acc();
void search_acc();
void return_main();

//---------------------------------------main-----------------------------------------------------
main()
{
    int x;
        cout<<"\t\t\t ****************************\n";
        cout<<"\t\t\t    STUDENT ENROLLMENT DATA\t\t\t";
        cout<<"\t\t\t \t       by zeeshan ashraf\t\t\t";
        cout<<"\t\t\t\t ****************************\t\n\n";
        cout<<"------------------------------------------------\n\n";
        cout<<"| 1. ADD RECORD                    \n\n";
        cout<<"| 2. SHOW  RECORD                           \n\n";
        cout<<"| 3. EXIT PROGRAM                                     \n\n";
        cout<<"------------------------------------------------\n\n";
        cout<<"*******************\n\n";
        cout<<"ENTER YOUR CHOISE:\n";
        cin>>x;
        cout<<"\n*******************\n";
        switch(x)
        {
        case 1:
        create_acc();
        case 2:
        search_acc();
        case 3:
        char ext;
        cout<<"are you sre you want to exit Y|N "<<endl;
        cin>>ext;
        if(ext=='y'||ext=='Y')
        {
        cout<<"bye"<<endl;
        getch();
        exit(EXIT_SUCCESS);
        }
        else
        {
        return_main();
        }
        }
}
//------------------------------------------------functin to add record-------------------------------------
 void create_acc()
{
   
      shan st;
      char n;
      ofstream zeeshan;
      zeeshan.open("zeeshan.txt",ios::out | ios::app);                                  
      cout<<"student registration data form."<<endl<<endl;
      zeeshan<<"student registration data form."<<endl<<endl;
for(int i=0;i<=20;i++)
{
    cout<<"*^*^*^*^*^*^*^*^*^*^*^*^*"<<endl;
    zeeshan<<"*^*^*^*^*^*^*^*^*^*^*^*^*"<<endl;
    cout<<"record:"<<endl<<endl;
    zeeshan<<"record:"<<endl<<endl;
    cout<<"student MISID:\t"<<endl;
    cin>>st.MISID;
    zeeshan<<"student MISID:\t"<<st.MISID<<endl;
    cout<<"student name:\t"<<endl;
    cin>>st.name;
    zeeshan<<"student name:\t"<<st.name<<endl;
    cout<<"student father name:\t"<<endl;
    cin>>st.father_name;
    zeeshan<<"student father name:\t"<<st.father_name<<endl;
    cout<<"department:\t"<<endl;
    cin>>st.department;
    zeeshan<<"department:\t"<<st.department<<endl;
    cout<<"registration:\t"<<endl;
    cin>>st.registration;
    zeeshan<<"registration:\t"<<st.registration<<endl;
    cout<<"title of degree:\t"<<endl;
    cin>>st.title_of_degree;
    zeeshan<<"title of degree:\t"<<st.title_of_degree<<endl;
    cout<<"semester:\t"<<endl;
    cin>>st.semester;
    zeeshan<<"semester:\t"<<st.semester<<endl;
    cout<<"shift:\t"<<endl;
    cin>>st.shift;
    zeeshan<<"shift:\t"<<st.shift<<endl<<endl;
    cout<<"subject 1:\t"<<endl;
    cin>>st.sub1;
    zeeshan<<"subject 1:\t"<<st.sub1<<endl;
    cout<<"subject 1 code:\t"<<endl;
    cin>>st.sub1_code;
    zeeshan<<"subject 1 code:\t"<<st.sub1_code<<endl;
    cout<<"subject 1 credit hours:\t"<<endl;
    cin>>st.sub1_credit_hours;
    zeeshan<<"subject 1 credit hours:\t"<<st.sub1_credit_hours<<endl;
    cout<<"subject 1 marks:\t"<<endl;
    cin>>st.sub1_marks;
    zeeshan<<"subject 1 marks:\t"<<st.sub1_marks<<endl<<endl;
    cout<<"subject 2:\t"<<endl;
    cin>>st.sub2;
    zeeshan<<"subject 2:\t"<<st.sub2<<endl;
    cout<<"subject 2 code:\t"<<endl;
    cin>>st.sub2_code;
    zeeshan<<"subject 2 code:\t"<<st.sub2_code<<endl;
    cout<<"subject 2 credit hours:\t"<<endl;
    cin>>st.sub2_credit_hours;
    zeeshan<<"subject 2 credit hours:\t"<<st.sub2_credit_hours<<endl;
    cout<<"subject 2 marks:\t"<<endl;
    cin>>st.sub2_marks;
    zeeshan<<"subject 2 marks:\t"<<st.sub2_marks<<endl<<endl;
    cout<<"subject 3:\t"<<endl;
    cin>>st.sub3;
    zeeshan<<"subject 3:\t"<<st.sub3<<endl;
    cout<<"subject 3 code:\t"<<endl;
    cin>>st.sub3_code;
    zeeshan<<"subject 3 code:\t"<<st.sub3_code<<endl;
    cout<<"subject 3 credit hours:\t"<<endl;
    cin>>st.sub3_credit_hours;
    zeeshan<<"subject 3 credit hours:\t"<<st.sub3_credit_hours<<endl;
    cout<<"subject 3 marks:\t"<<endl;
    cin>>st.sub3_marks;
    zeeshan<<"subject 3 marks:\t"<<st.sub3_marks<<endl<<endl;
    cout<<"subject 4:\t"<<endl;
    cin>>st.sub4;
    zeeshan<<"subject 4:\t"<<st.sub4<<endl;
    cout<<"subject 4 code:\t"<<endl;
    cin>>st.sub4_code;
    zeeshan<<"subject 4 code:\t"<<st.sub4_code<<endl;
    cout<<"subject 4 credit hours:\t"<<endl;
    cin>>st.sub4_credit_hours;
    zeeshan<<"subject 4 credit hours:\t"<<st.sub4_credit_hours<<endl;
    cout<<"subject 4 marks:\t"<<endl;
    cin>>st.sub4_marks;
    zeeshan<<"subject 4 marks:\t"<<st.sub4_marks<<endl<<endl;
    cout<<"subject 5:\t"<<endl;
    cin>>st.sub5;
    zeeshan<<"subject 5:\t"<<st.sub5<<endl;
    cout<<"subject 5 code:\t"<<endl;
    cin>>st.sub3_code;
    zeeshan<<"subject 5 code:\t"<<st.sub5_code<<endl;
    cout<<"subject 5 credit hours:\t"<<endl;
    cin>>st.sub5_credit_hours;
    zeeshan<<"subject 5 credit hours:\t"<<st.sub5_credit_hours<<endl;
    cout<<"subject 5 marks:\t"<<endl;
    cin>>st.sub5_marks;
    zeeshan<<"subject 5 marks:\t"<<st.sub5_marks<<endl<<endl;
    cout<<"subject 6:\t"<<endl;
    cin>>st.sub6;
    zeeshan<<"subject 6:\t"<<st.sub6<<endl;
    cout<<"subject 6 code:\t"<<endl;
    cin>>st.sub6_code;
    zeeshan<<"subject 6 code:\t"<<st.sub6_code<<endl;
    cout<<"subject 6 credit hours:\t"<<endl;
    cin>>st.sub6_credit_hours;
    zeeshan<<"subject 6 credit hours:\t"<<st.sub6_credit_hours<<endl;
    cout<<"subject 6 marks:\t"<<endl;
    cin>>st.sub6_marks;
    zeeshan<<"subject 6 marks:\t"<<st.sub6_marks<<endl<<endl;

    cout<<"if u want to save some more data type n for next."<<endl<<endl;
    cin>>n;
    if(n=='n'||n=='N')
    {
    cout<<"**********"<<endl;
    }
    else
    {
    cout<<"bye..!"<<endl;
    break;
    }}
    return_main();
    }
//--------------------------------------------function to return to main------------------------------
void return_main()
{
     char f[2];
     cout<<"\n\n Press any key to return to main menu ";
     cin>>f;
     system("cls");
     main();
     }
 //--------------------------------------------function to show record----------------------------          
void search_acc()
{
 char f;
 cout<<"\tpress f to read record:\t\n\n";
 cin>>f;
if(f=='f'||f=='F')
 {
  string line;
  ifstream zeeshan;
  zeeshan.open ("zeeshan.txt");
if (zeeshan.is_open())
  {
  while ( zeeshan.good() )
  {
  getline (zeeshan,line);
  cout << line << endl;
  }
  zeeshan.close();
  return_main();
  }
  }            
else
  {
  cout<< "\aUnable to open file";
  }
  return_main();
  }
           
   
   
   
   
   
   
   
   
   

No comments:

Post a Comment