Hy!
I have a project and hav to submit it at 13 june.
Can somebody help me to add "Search Code" in this code. Its a student class a data abt student. If i want to search student data printed as
Name:
Father name:
Id:
and other data like this if i only enter student id. Plzzzzzzzzz help me
Thanx a lot.
My code is:
#include<iostream>
#include<vector>
#include<string>
using namespace std;
class student
{
private:
string name;
string father_name;
string id_no;
int age;
string gender;
string religion;
int semester;
string course;
string code;
string c_hrs;
double marks;
public:
student():name(),father_name(),id_no(),age(),gender(),religion(),semester()
{}
student(string n,string fn,string id,int a,string g,string r,int sem):name(n),father_name(fn),id_no(id),age(a),gender(g),religion(r),semester(sem)
{}
student(string n,string id,string c,double m):name(n),id_no(id),course(c),marks(m)
{}
void get_data()
{
cout<<" ***** MANUE ***** "<<endl;
cout<<" 1: Post Graduate Student "<<endl;
cout<<" 2: Under Graduate Student "<<endl;
cout<<"Your choice?"<<endl;
int choice;
cin>>choice;
switch (choice)
{
case 1:
cout<<"*** Enter Name of Student ***"<<endl;
cin>>name;
cout<<"*** Enter Father Name of Student ***"<<endl;
cin>>father_name;
cout<<"*** Enter Student Id(registration num)"<<endl;
cin>>id_no;
cout<<" *** Enter Gender of Student ***"<<endl;
cin>>gender;
cout<<" *** Enter Relegion of Student ***"<<endl;
cin>>religion;
cout<<"*** Enter Current Semester *** "<<endl;
int sem_no;
cin>>sem_no;
if(sem_no == 1)
{
cout<<'\t'<<"Courses Offered"<<endl;
cout<<'\t'<<"1.(BI401) Methods in BI"<<endl<<'\t'<<"2.(BI135) Moleculer Bio"<<endl;
cout<<'\t'<<"3.(BI201) Modeling & Simulation"<<endl<<'\t'<<"4.(CS105) Artifical intellegence"<<endl;
cout<<" How many Courses You want to Take in a Semester? "<<endl;
int c;
cin>>c;
if(c>4)
{
cout<<"Only 4 Courses are offered in a Semester! "<<endl;
}
cout<<" Fee for one Course is 9000"<<endl;
double fee= c*(9000);
cout<<"Your Total Fee for this Semester is :"<<endl<<fee<<endl;
string e;
double TotalFee ;
cout<<" Do u want to drop course ?? (y/n) "<<endl;
//char e;
cin>>e;
if(e=="y")
{
cout<<" How many courses ?? "<<endl;
int s;
cin>>s;
int course = c -s;
TotalFee =fee-s*(7000);
cout<<"Now your Fee is:"<<endl<<TotalFee<<endl;
}
else
{
cout<<" Error!! "<<endl;
}
}
else if(sem_no == 2)
{
cout<<'\t'<<"Course Offered"<<endl;
cout<<'\t'<<"1.(BI402) Advance BI"<<endl<<'\t'<<"2.(BI136) Technices in Moleculer"<<endl;
cout<<'\t'<<"3.(BI202) Theory of Automata "<<endl<<'\t'<<"4.(CS106) Computer Graphics"<<endl;
cout<<" How many Courses You want to Take in a Semester? "<<endl;
int c;
cin>>c;
if(c>4)
{
cout<<"Only 4 Courses are offered in a Semester! "<<endl;
}
cout<<" Fee for one Course is 9000"<<endl;
double fee= c*(9000);
cout<<"Your Total Fee for this Semester is :"<<endl<<fee<<endl;
string e;
double TotalFee ;
cout<<" Do u want to drop course ?? (y/n) "<<endl;
//char e;
cin>>e;
if(e=="y")
{
cout<<" How many courses ?? "<<endl;
int s;
cin>>s;
int course = c -s;
TotalFee =fee-s*(7000);
cout<<"Now your Fee is:"<<endl<<TotalFee<<endl;
}
else
{
cout<<" Error!! "<<endl;
}
}
else
{
cout<<"Only 2 Semesters are offered in Ms"<<endl;
}
break;
case 2:
cout<<"*** Enter Name of Student ***"<<endl;
cin>>name;
cout<<"*** Enter Father Name of Student ***"<<endl;
cin>>father_name;
cout<<"*** Enter Student Id(registration num)"<<endl;
cin>>id_no;
cout<<" *** Enter Gender of Student ***"<<endl;
cin>>gender;
cout<<" *** Enter Relegion of Student ***"<<endl;
cin>>religion;
cout<<"*** Enter Current Semester *** "<<endl;
//int sem_no;
cin>>sem_no;
if(sem_no == 1)
{
cout<<'\t'<<"** Courses Offered **"<<endl;
cout<<'\t'<<"1.(UR301) Functional English"<<endl<<'\t'<<"2.(BI137) Cell Bio"<<endl;
cout<<'\t'<<"3.(BI203) Elementry Maths "<<endl<<'\t'<<"4.(UR302) Functional Arabic "<<endl;
cout<<" How many Courses You want to Take in a Semester? "<<endl;
int c;
cin>>c;
if(c>4)
{
cout<<"Only 4 Courses are offered in a Semester! "<<endl;
}
cout<<" Fee for one Course is 7000"<<endl;
double fee= c*(7000);
cout<<"Your Total Fee for this Semester is :"<<endl<<fee<<endl;
string e;
double TotalFee ;
cout<<" Do u want to drop course ?? (y/n) "<<endl;
//char e;
cin>>e;
if(e=="y")
{
cout<<" How many courses ?? "<<endl;
int s;
cin>>s;
int course = c -s;
TotalFee =fee-s*(7000);
cout<<"Now your Fee is:"<<endl<<TotalFee<<endl;
}
else
{
cout<<" Error!! "<<endl;
}
}
else if(sem_no == 2)
{
cout<<'\t'<<" ** Course Offered **"<<endl;
cout<<'\t'<<" 1.(BI138) Intro to BI"<<endl<<'\t'<<" 2.(BI139) Fundamental Genetics "<<endl;
cout<<'\t'<<" 3.(BI204) Linear Theory "<<endl<<'\t'<<" 4.(CS102) Algorithim "<<endl;
cout<<" How many Courses You want to Take in a Semester? "<<endl;
int c;
cin>>c;
if(c>4)
{
cout<<"Only 4 Courses are offered in a Semester! "<<endl;
}
cout<<" Fee for one Course is 7000"<<endl;
double fee= c*(7000);
cout<<"Your Total Fee for this Semester is :"<<endl<<fee<<endl;
string e;
double TotalFee ;
cout<<" Do u want to drop course ?? (y/n) "<<endl;
//char e;
cin>>e;
if(e=="y")
{
cout<<" How many courses ?? "<<endl;
int s;
cin>>s;
int course = c -s;
TotalFee =fee-s*(7000);
cout<<"Now your Fee is:"<<endl<<TotalFee<<endl;
}
else
{
cout<<" Error!! "<<endl;
}
}
else if(sem_no == 3)
{
cout<<'\t'<<" ** Course Offered ** "<<endl;
cout<<'\t'<<"1.(BI140) Techniques of BI"<<endl<<'\t'<<"2.(BI141) Bio Ethics"<<endl;
cout<<'\t'<<"3.(BI205) Differential Equation "<<endl<<'\t'<<"4.(CS104) Java "<<endl;
cout<<" How many Courses You want to Take in a Semester? "<<endl;
int c;
cin>>c;
if(c>4)
{
cout<<"Only 4 Courses are offered in a Semester! "<<endl;
}
cout<<" Fee for one Course is 7000"<<endl;
double fee= c*(7000);
cout<<"Your Total Fee for this Semester is :"<<endl<<fee<<endl;
string e;
double TotalFee ;
cout<<" Do u want to drop course ?? (y/n) "<<endl;
//char e;
cin>>e;
if(e=="y")
{
cout<<" How many courses ?? "<<endl;
int s;
cin>>s;
int course = c -s;
TotalFee =fee-s*(7000);
cout<<"Now your Fee is:"<<endl<<TotalFee<<endl;
}
else
{
cout<<" Error!! "<<endl;
}
}
else if(sem_no == 4)
{
cout<<'\t'<<" ** Course Offered ** "<<endl;
cout<<'\t'<<"1.(BI142) Advance methods in BI"<<endl<<'\t'<<"2.(BI143) Nano Technology"<<endl;
cout<<'\t'<<"3.(BI206) BI Software Development "<<endl<<'\t'<<"4.(CS101) Data Structure "<<endl;
cout<<" How many Courses You want to Take in a Semester? "<<endl;
int c;
cin>>c;
if(c>4)
{
cout<<"Only 4 Courses are offered in a Semester! "<<endl;
}
cout<<" Fee for one Course is 7000"<<endl;
double fee= c*(7000);
cout<<"Your Total Fee for this Semester is :"<<endl<<fee<<endl;
string e;
double TotalFee ;
cout<<" Do u want to drop course ?? (y/n) "<<endl;
//char e;
cin>>e;
if(e=="y")
{
cout<<" How many courses ?? "<<endl;
int s;
cin>>s;
int course = c -s;
TotalFee =fee-s*(7000);
cout<<"Now your Fee is:"<<endl<<TotalFee<<endl;
}
else
{
cout<<" Error!! "<<endl;
}
}
else
{
cout<<"Only 4 Semesters are ofered at Bs level"<<endl;
}
break;
default:
{
cout<<"Invalid Option!"<<endl;
}
}
}
double Cal_GPA( )
{
float marks;
float GPA;
float CGPA = 0.0;
string grade;
int count;
cout<<"Enter the no of subjects student took"<<endl;
cin>>count;
for(int i=1; i<=count; i++)
{
cout<<"Enter the marks obtained"<<endl;
cin>>marks;
if(marks >= 80)
{
grade = "A";
GPA= 4.0;
CGPA +=GPA/count;
cout<<"Your Grade is :"<<grade<<endl;
cout<<"Your GPA is : "<<GPA<<endl;
cout<<"Your CGPA is : "<<CGPA<<endl;
}
else if ((marks >= 75)&&(marks < 80))
{
grade = "B+";
GPA= 3.5;
CGPA +=GPA/count;
cout<<"Your Grade is :"<<grade<<endl;
cout<<"Your GPA is : "<<GPA<<endl;
cout<<"Your CGPA is : "<<CGPA<<endl;
}
else if((marks >= 70)&&(marks < 75))
{ grade = "B";
GPA= 3.0;
CGPA +=GPA/count;
cout<<"Your Grade is :"<<grade<<endl;
cout<<"Your GPA is : "<<GPA<<endl;
cout<<"Your CGPA is : "<<CGPA<<endl;
}
else if((marks >= 65)&&(marks < 70))
{
grade = "C+";
GPA= 2.5;
CGPA +=GPA/count;
cout<<"Your Grade is :"<<grade<<endl;
cout<<"Your GPA is : "<<GPA<<endl;
cout<<"Your CGPA is : "<<CGPA<<endl;
}
else if((marks >= 60)&&(marks < 65))
{
grade = "C";
GPA= 2.0;
CGPA +=GPA/count;
cout<<"Your Grade is :"<<grade<<endl;
cout<<"Your GPA is : "<<GPA<<endl;
cout<<"Your CGPA is : "<<CGPA<<endl;
}
else
{
grade = "F";
GPA= 0.0;
CGPA +=GPA/count;
cout<<"Your Grade is :"<<grade<<endl;
cout<<"Your GPA is : "<<GPA<<endl;
cout<<"Your CGPA is : "<<CGPA<<endl;
}
}
return GPA;
}
void student_data()
{
cout<<" ********** Data Of Student ********** "<<endl;
cout<<"*** Enter Name of Student ***"<<endl;
cin>>name;
cout<<"*** Enter Father Name of Student ***"<<endl;
cin>>father_name;
cout<<"*** Enter Student Id(registration num)"<<endl;
cin>>id_no;
cout<<" *** Enter Gender of Student ***"<<endl;
cin>>gender;
cout<<" *** Enter Relegion of Student ***"<<endl;
cin>>religion;
cout<<"The name is:"<<name<<endl;
cout<<"The registration no:"<<id_no<<endl;
//cout<<"The age is:"<<age<<endl;
}
};
void main()
{
student s;
int choice;
cout<<'\t'<<"***********************************************************"<<'\t'<<endl;
cout<<'\t'<<"|..........................................................|"<<'\t'<<endl;
cout<<'\t'<<"*********** INTERNATIONAL ISLAMIC UNIVERSITY ************"<<'\t'<<endl;
cout<<'\t'<<"|...................ISLAMABAD..............................|"<<'\t'<<endl;
cout<<'\t'<<"***********************************************************"<<'\t'<<endl;
cout<<'\n'<<endl;
cout<<'\n'<<endl;
cout<<'\t'<<"***********************************************************"<<'\t'<<endl;
cout<<'\t'<<"|.........................................................|"<<'\t'<<endl;
cout<<'\t'<<"*********** DEPARTMENT OF ************"<<'\t'<<endl;
cout<<'\t'<<"|.....................BIOINFORMATICS......................|"<<'\t'<<endl;
cout<<'\t'<<"***********************************************************"<<'\t'<<endl;
cout<<'\n'<<endl;
cout<<'\n'<<endl;
cout<<'\t'<<"...................................."<<'\t'<<endl;
cout<<'\t'<<"| |"<<'\t'<<endl;
cout<<'\t'<<"*********** MAIN MANUE ************"<<'\t'<<endl;
cout<<'\t'<<"| |"<<'\t'<<endl;
cout<<'\t'<<"...................................."<<'\t'<<endl;
cout<<'\n'<<endl;
cout<<'\t'<<" 1: ** Add Data **"<<endl<<'\t'<<" 2: ** Search/View Data **"<<endl;
cout<<'\t'<<" 3: ** Calculate GPA **"<<endl<<'\t'<<" 4: ** Exit **"<<endl;
cout<<" Enter the option you want to operate??? "<<endl;
cout<<" 4 is to exit from main manue "<<endl;
cin>>choice;
if (choice == 1)
{
cout<<'\t'<<".................................."<<'\t'<<endl;
cout<<'\t'<<"*********** ADD MANUE ************"<<'\t'<<endl;
cout<<'\t'<<".................................."<<'\t'<<endl;
cout<<'\t'<<" 1: Add Data of PostGraduate Student "<<endl<<'\t'<<" 2: Add Data of UnderGraduate Student "<<endl;
cout<<'\t'<<" 3: Exit"<<endl;
cout<<" Enter your choice "<<endl;
cin>>choice;
switch(choice)
{
case 1:
//cout<<'\t'<<"***** Data of Post Graduate Student *****"<<endl;
s.get_data();
break;
case 2:
//cout<<'\t'<<"***** Data of Under Graduate Student *****"<<endl;
s.get_data();
break;
//case 3:
// exit;
default:
cout<<"invalid option"<<endl;
}
}
else if (choice == 2)
{
cout<<'\t'<<"....................................."<<'\t'<<endl;
cout<<'\t'<<"*********** SEARCH MANUE ************"<<'\t'<<endl;
cout<<'\t'<<"....................................."<<'\t'<<endl;
cout<<'\t'<<" 1: Search Data of PostGraduate Student "<<endl<<'\t'<<" 2: Search Data of UnderGraduate Student "<<endl;
cout<<'\t'<<" 3: Exit"<<endl;
cout<<" Enter your choice "<<endl;
cin>>choice;
switch(choice)
{
case 1:
cout<<'\t'<<"***** Data of Post Graduate Student *****"<<endl;
cout<<" You only can search data by Student Id "<<endl;
cout<<"Enter Student id"<<endl;
s.student_data();
break;
case 2:
cout<<'\t'<<"***** Data of Under Graduate Student *****"<<endl;
cout<<" You only can search data by Student Id "<<endl;
cout<<"Enter Student id"<<endl;
//cin>>id_no;
s.student_data();
// vs.push_back(new student(s));
break;
case 3:
exit;
default:
cout<<"invalid option"<<endl;
}
}
else if (choice == 3)
{
cout<<'\t'<<".................................."<<'\t'<<endl;
cout<<'\t'<<"*********** GPA MANUE ************"<<'\t'<<endl;
cout<<'\t'<<".................................."<<'\t'<<endl;
cout<<'\t'<<" 1: Calculate GPA of PostGraduate Student "<<endl<<'\t'<<" 2: Calculate GPA of UnderGraduate Student "<<endl;
cout<<'\t'<<" 3: Exit"<<endl;
cout<<" Enter your choice "<<endl;
cin>>choice;
switch(choice)
{
case 1:
cout<<'\t'<<"***** Data of Post Graduate Student *****"<<endl;
cout<<"For Post Graduate Students only 4 subjects are offered"<<endl;
cout<<"Only 2 semesters are offered in Ms"<<endl;
s.Cal_GPA( );
break;
case 2:
cout<<'\t'<<"***** Data of Under Graduate Student *****"<<endl;
cout<<"For Under Graduate Students only 4 subjects are offered"<<endl;
cout<<"Only 4 semesters are offered in Bs"<<endl;
s.Cal_GPA( );
break;
case 3:
exit;
default:
cout<<"invalid option"<<endl;
}
}
}