c++ programm2
c++ programm2
#include <string>
#include <iomanip>
using namespace std;
}
void display(int n, struct Student students[]) {
// Q.2 Display the information
cout << endl<<"Displaying Information of Students:" << endl;
cout << "Sno |";
cout <<setw(15)<< "Student Id | ";
cout<<setw(15) << "First Name |";
cout <<setw(15)<< "Father Name |";
cout <<setw(16)<<"G.Father Name |";
cout <<setw(5)<< "Sex |";
cout <<setw(5)<< "dept |";
cout <<setw(10)<< "Mid(40%)|";
cout <<setw(10)<< "final(60%)|";
cout <<setw(5)<< "Grade |"<<endl;
for (int i = 0; i < n; ++i) {
cout<<"____________________________________________________________________________
_________________________________\n";
cout <<setw(3)<<students[i].Sno<<"|" ;
cout <<setw(14)<< students[i].Student_Id <<"|";
cout <<setw(15)<< students[i].First_Name <<"|";
cout <<setw(15)<< students[i].Father_Name <<"|";
cout <<setw(14)<< students[i].G_Father_Name<<"|" ;
cout <<setw(5)<< students[i].Sex<<"|" ;
cout <<setw(5)<< students[i].dept<<"|" ;
cout <<setw(10)<< students[i].Mid <<"|";
cout <<setw(10)<< students[i].final<<"|";
cout<<"____________________________________________________________________________
_________________________________\n";
cout <<setw(3)<<students[i].Sno<<"|" ;
cout <<setw(14)<< students[i].Student_Id <<"|";
cout <<setw(15)<< students[i].First_Name <<"|";
cout <<setw(15)<< students[i].Father_Name <<"|";
cout <<setw(14)<< students[i].G_Father_Name<<"|" ;
cout <<setw(5)<< students[i].Sex<<"|" ;
cout <<setw(5)<< students[i].dept<<"|" ;
cout <<setw(10)<< students[i].Mid <<"|";
cout <<setw(10)<< students[i].final<<"|";
}
}
cout<<"\n Total student for \""<<check<<"\" Department is : "<<counter<<endl;
cout<<"\n Do you want to check other department ? Y/N \n";
string des;
cin>>des;
if((des=="Y")||(des=="y")){
goto M;
}
else if((des=="N")||(des=="n")){
cout<<"10Q \n";
}
}
void overallgrade(int n, struct Student students[]){
// grade for total student average
int sum=0;
int average;
for(int i=0;i<n;i++){
sum +=students[i].Mid + students[i].final;
}
average=sum/n;
string grade;
if(average>=90){
grade="A+";
}
else if (average>=85){
grade="A";
}
else if (average>=80){
grade="A-";
}
else if (average>=75){
grade="B+";
}
else if (average>=70){
grade="B";
}
else if (average>=65){
grade="B-";
}
else if (average>=60){
grade="C+";
}
else if (average>=55){
grade="C";
}
else if (average>=50){
grade="C-";
}
else if (average>=45){
grade="D";
}
else {
grade="F";
}
cout<<"\n average grade of all students is :"<<grade<<endl;
}
void dispbydept(int n, struct Student students[]) {
cout<<"____________________________________________________________________________
_________________________________\n";
cout <<setw(3)<<students[i].Sno<<"|" ;
cout <<setw(14)<< students[i].Student_Id <<"|";
cout <<setw(15)<< students[i].First_Name <<"|";
cout <<setw(15)<< students[i].Father_Name <<"|";
cout <<setw(14)<< students[i].G_Father_Name<<"|" ;
cout <<setw(5)<< students[i].Sex<<"|" ;
cout <<setw(5)<< students[i].dept<<"|" ;
cout <<setw(10)<< students[i].Mid <<"|";
cout <<setw(10)<< students[i].final<<"|";
}}
}}
int main() {
int n;
cout << "Enter the number of students: ";
cin >> n;
// Create an array of structures to store multiple student records
Student students[n];
M:
cout<<"*****************************************************";
cout<<"\n **** Enter your choose ****************\n";
cout<<"*****************************************************";
cout<<"\n *** 1: to register ***\n";
cout<<" *** ***";
cout<<"\n *** 2: to display all ***\n";
cout<<" *** ***";
cout<<"\n *** 3: to count & display by Department ***\n";
cout<<" *** ***";
cout<<"\n *** 4: to display grade of overall average ***\n";
cout<<" *** ***";
cout<<"\n *** 5: to display by department ***\n";
cout<<" *** ***";
cout<<"\n *** 6: to Exite ***\n";
cout<<"******************************************************\n\n";
//cout<<" *** ***";
int op;
cin>>op;
if(op==1){
addstud(n, students);
goto M;
}
else if(op==2){
display(n, students);
goto M;
}
else if(op==3) {
countdep(n, students);
goto M;
}
else if(op==4) {
overallgrade(n, students);
goto M;
}
else if(op==5) {
dispbydept(n, students);
goto M;
}
else if(op==6) {
Exit();
}else{
cout<<"you had enter invalid input: Please try again \n \n";
goto M;
}
return 0;
}