You are on page 1of 3

#include <iostream>

#include <cmath>
#include <string>
#include <iomanip>

using namespace std;

class Student
{
string name;
string f_name;
int Roll_No;
string Degree;
string Department;

public:
void input_data()
{
cin.ignore();
cout << endl;
cout << "Enter the name of Student:" << endl;
getline(cin, name);
cout << "Enter Father name of Student:" << endl;
getline(cin, f_name);
cout << "Enter Department of Student:" << endl;
getline(cin, Department);
cout << "Enter Degree of Student:" << endl;
getline(cin, Degree);
cout << "Enter the Roll Number of Student:" << endl;
cin >> Roll_No;
}

void display_all()
{
cout << "Name of Student is: " << name << endl;
cout << "The Father name of Student is: " << f_name << endl;
cout << "Roll number of student is : " << Roll_No << endl;
cout << "Department of Student is: " << Department << endl;
cout << "Degree of Student is: " << Degree << endl;
cout << endl;
cout << "-----------------" << endl;
}

void search(int roll1)


{

if (Roll_No == roll1)
{
cout << "Name of Student is: " << name << endl;
cout << "The Father name of Student is: " << f_name << endl;
cout << "Roll number of student is : " << Roll_No << endl;
cout << "Department of Student is: " << Department << endl;
cout << "Degree of Student is: " << Degree << endl;
cout << endl;
cout << "-----------------" << endl;
}
}

void delete_data()
{
int roll;
cout << "please enter the Roll number of user to delete its data:" << endl;
cin >> roll;

for (int i = 0; i < 2; i++)


{
if (Roll_No == roll)
{
name = "0";
f_name = "0";
Roll_No = 0;
Department = "0";
Degree = "0";

cout << "deleted" << endl;


continue;
}
}
}
};

int main()
{
int n;
Student E[2];

for (int i = 1; i > 0; i++)


{
cout << "Enter 1 for input data: " << endl;
cout << "Enter 2 for Display all data: " << endl;
cout << "Enter 3 for search data: " << endl;
cout << "Enter 4 for delete data: " << endl;
cin >> n;
if (n == 1)
{
for (int i = 0; i < 2; i++)
{
E[i].input_data();
}
}
else if (n == 2)
{
for (int i = 0; i < 2; i++)
{
E[i].display_all();
}
}

else if (n == 3)
{
int roll;
cout << "please enter the Roll number of Student to find its detail:"
<< endl;
cin >> roll;
for (int i = 0; i < 2; i++)
{
E[i].search(roll);
}
}
else if (n == 4)
{
for (int i = 0; i < 2; i++)
{
E[i].delete_data();
}
}
continue;
}
return 0;
}

You might also like