Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 8

#include<iostream>

#include<string>
using namespace std;
int Record = 0;
struct Student
{
private:
int ID[50];
string Name[50];
float CS[50], Math[50], Phy[50], Eng[50];
public:
char choice;
void addStudentsmarks()
{
for (int i = 0; i<50; i++)
{

Record++;
cout << "Enter student roll number" << endl;
cin >> ID[i];
cout << "Enter student Name" << endl;
cin.ignore();
getline(cin, Name[i]);
cout << "Enter marks of math of student " << ID[i] << " within
100" << endl;
cin >> Math[i];
while (Math[i]<0 || Math[i] > 100)
{

cout << "Again Enter marks of math of student " << ID[i] <<
" within 100" << endl;
cin >> Math[i];

cout << "Enter marks of computer science of student " << ID[i]
<< " within 100" << endl;
cin >> CS[i];
while (CS[i] < 0 || CS[i] > 100)
{
cout << "Again Enter marks of computer science of student
" << ID[i] << " within 100" << endl;
cin >> CS[i];
}

cout << "Enter marks of PHYSICS of student " << ID[i] << "
within 100" << endl;
cin >> Phy[i];
while (Phy[i]<0 || Phy[i] > 100)
{
cout << "Again Enter marks of Physics of student " << ID[i]
<< " within 100" << endl;
cin >> Phy[i];
}

cout << "Enter marks of English of student " << ID[i] << "
within 100" << endl;
cin >> Eng[i];
while (Eng[i]<0 || Eng[i]>100)
{
cout << "Again Enter marks of English of student " <<
ID[i] << " within 100" << endl;
cin >> Eng[i];
}

cout << "Enter Y/y for continue adding students and N/n for stop"
<< endl;
cin >> choice;
if (choice == 'N' || choice == 'n')
{
break;
}
else if (ID[i] == 50 && Math[i] == 50 && CS[i] == 50)
{
cout << "Array is full";
break;
}

}
}
//1 Update the Roll Number of Particular Student
void updateRollNumber(int id)
{
int roll = id;
for (int i = 0; i<Record; i++)
{
if (ID[i] == roll)
{
cout << "Enter new roll no of student" << endl;
cin >> roll;
ID[i] = roll;
break;
}
}
}
//2 Update the Marks of CS of Particular Student
void updateMarksCs(int rollNo)
{
float newmarks;
for (int i = 0; i<Record; i++)
{
if (ID[i] == rollNo)
{

cout << "Enter new marks of student " << ID[i] << " for CS"
<< endl;
cin >> newmarks;
CS[i] = newmarks;
break;
}
}
}
//3 Update All the marks of CS of all Students
void updateALLMarksCs()
{
int i;
for (i = 0; i<Record; i++)
{
cout << "Enter marks of computer science of student " << ID[i]
<< " within 100" << endl;
cin >> CS[i];

while (CS[i]<0 || CS[i]>100)


{
cout << "Again Enter marks of computer science of student
within 100" << endl;
CS[i];
}

}
if (CS[i] == 50)
{
cout << "Array is full" << endl;
}

}
//4 Update marks of Math of particular Student
void updateMarksMath(int rollNumber)
{
float newmarks;
for (int i = 0; i<Record; i++)
{
if (ID[i] == rollNumber)
{
cout << "Enter new marks of student for Math of student "
<< ID[i] << endl;
cin >> newmarks;
Math[i] = newmarks;
break;
}
}
}
//5 Update Marks of CS of All Student
void updateALLMarksMath(){
for (int i = 0; i<Record; i++)
{
cout << "Enter marks of math of student " << ID[i] << " within
100" << endl;
cin >> Math[i];
while (Math[i]<0 || Math[i] > 100)
{
cout << "Again Enter marks of computer science of student
within 100" << endl;
Math[i];
}
if (Math[i] == 50)
{
cout << "Array is full" << endl;
}
}
}
//6 Update marks of English Marks of Particular Student
void updateMarksEng(int rollNo)
{
float newmarks;
for (int i = 0; i<Record; i++)
{
if (ID[i] == rollNo)
{

cout << "Enter new marks of student " << ID[i] << " for CS"
<< endl;
cin >> newmarks;
Eng[i] = newmarks;
break;
}
}
}
//7 Update Marks of English Marks of all students
void updateALLMarksEng()
{
for (int i = 0; i<Record; i++)
{
cout << "Enter marks of math of student " << ID[i] << " within
100" << endl;
cin >> Eng[i];
while (Eng[i]<0 || Eng[i] > 100)
{
cout << "Again Enter marks of computer science of student
within 100" << endl;
Eng[i];
}
if (Eng[i] == 50)
{
cout << "Array is full" << endl;
}
}
}
//8 Update Marks of Physics of Particular student
void updateMarksPhysics(int rollNo)
{
float newmarks;
for (int i = 0; i<Record; i++)
{
if (ID[i] == rollNo)
{

cout << "Enter new marks of student " << ID[i] << " for CS"
<< endl;
cin >> newmarks;
Phy[i] = newmarks;
break;
}
}
}

//9 Update Marks of Physics of all student


void updateALLMarksPhysics()
{
for (int i = 0; i<Record; i++)
{
cout << "Enter marks of math of student " << ID[i] << " within
100" << endl;
cin >> Phy[i];
while (Phy[i]<0 || Phy[i] > 100)
{
cout << "Again Enter marks of computer science of student
within 100" << endl;
Phy[i];
}
if (Phy[i] == 50)
{
cout << "Array is full" << endl;
}
}
}
//10 Delete the Record of Student
void deleteStudent(int rollNumb)
{
for (int i = 0; i<Record; i++)
{
if (ID[i] == rollNumb)
{
ID[i] = 0;
Math[i] = 0;
CS[i] = 0;
Eng[i]=0;
Phy[i] = 0;
}
}
}
//11 Find the percentage and Grade of student Also Print first Box of Output
void percentageGrade(){
for (int i = 0; i<Record; i++){
if (ID[i] && Math[i] && CS[i]){
cout << endl <<
"==================================================================================
===" << endl;

cout << "Roll number of student " << Name[i] << " is: " <<
ID[i] << endl;
cout << "Marks of math of student " << Name[i] << " is: "
<< Math[i] << endl;
cout << "Marks of computer science of student " << Name[i]
<< " is: " << CS[i] << endl;
cout << "Marks of Physics of student " << Name[i] << " is:
" << Phy[i] << endl;
cout << "Marks of English of student " << Name[i] << " is:
" << Eng[i] << endl;
int percentage = (Math[i] + CS[i] + Phy[i] + Eng[i]) *
100 / 400;
cout << "Percentage of student " << Name[i] << " is: " <<
(Math[i] + CS[i] + Phy[i] + Eng[i]) * 100 / 400 << endl;
if (percentage >= 91 && percentage <= 100){
cout << "Grade of student " << Name[i] << " is: " <<
"A" << endl;
}
else if (percentage >= 75 && percentage <= 90){
cout << "Grade of student " << Name[i] << " is: " <<
"B" << endl;

}
else if (percentage >= 60 && percentage<75){
cout << "Grade of student " << Name[i] << " is: " <<
"C" << endl;

}
else if (percentage >= 50 && percentage<60){
cout << "Grade of student " << Name[i] << " is: " <<
"D" << endl;
}
else{
cout << "Grade of student " << Name[i] << " is: " <<
"F" << endl;
}
}
}
}
//12 Print the Final output
void finalDisplay(){
cout <<
"============================================================================" <<
endl << endl;
cout << "Roll number " << " Name " << " Math " << "
CS " << " Physics " << " English " << endl << endl;
cout <<
"----------------------------------------------------------------------------" <<
endl << endl;
for (int i = 0; i<Record; i++){
cout << ID[i] << " " << Name[i] << " " << Math[i]
<< " " << CS[i] << " " << Phy[i] << " " << Eng[i] << endl;
}
cout <<
"============================================================================" <<
endl << endl;
cout << " FININSH" << endl << endl;
cout <<
"----------------------------------------------------------------------------" <<
endl << endl;

}
};

//Main start

int main()
{
Student A;
char choice;
A.addStudentsmarks();
cout << "Enter Y/y to for advance operations and their data and N/n to stop:"
<< endl;
cin >> choice;
if (choice == 'Y' || choice == 'y')
{
int choice2 = 0;
while (choice2 != 11){
cout << "Press 1 to update Roll Number of a particular Student."
<< endl;
cout << "Press 2 to update marks of a particular student for CS."
<< endl;
cout << "Press 3 to update marks of CS for all students who are
already enrolled." << endl;
cout << "Press 4 to update marks for Mathematics." << endl;
cout << "Press 5 to update marks of Mathematics for all students
who are already enrolled." << endl;
cout << "Press 6 to update marks for English." << endl;
cout << "Press 7 to update marks of a particular student for
English." << endl;
cout << "Press 8 to update marks of English for all students who
are already enrolled." << endl;
cout << "Press 9 to update marks for Physics." << endl;
cout << "Press 10 to delete the record of a particular student"
<< endl;
cout << "Press 11 for Exit" << endl;
cin >> choice2;
switch (choice2)
{
case 1:
int rollno;
cout << "Enter Roll number of particular student" << endl;
cin >> rollno;
A.updateRollNumber(rollno);

break;

case 2:
int rollNo;
cout << "Enter Roll number of particular student" << endl;
cin >> rollNo;

A.updateMarksCs(rollNo);

break;

case 3:
A.updateALLMarksCs();
break;

case 4:
int rollNumber;
cout << "Enter Roll number of particular student" << endl;
cin >> rollNumber;

A.updateMarksMath(rollNumber);
break;

case 5:
A.updateALLMarksMath();
break;

case 6:
int rollNumber1;
cout << "Enter Roll number of particular student" << endl;
cin >> rollNumber1;

A.updateMarksEng(rollNumber1);
break;

case 7:
A.updateALLMarksEng();
break;
case 8:
int rollNumber2;
cout << "Enter Roll number of particular student" << endl;
cin >> rollNumber2;

A.updateMarksPhysics(rollNumber2);
break;

case 9:
A.updateALLMarksPhysics();
break;
case 10:
int rollNumb;
cout << "Enter Roll number of particular student" << endl;
cin >> rollNumb;
A.deleteStudent(rollNumb);

break;
}
}
}
A.percentageGrade();
A.finalDisplay();
}

You might also like