Question #315909

Create a structure course with some attributes i.e course_ID, course_title, credit_hrs etc.. Then Implement following 5 functions (Known as CRUDS operations which means CREATE, READ, UPDATE, DELETE, SEARCH operations):


1. addAStudent

2. updateAStudent

3. deleteAStudent

4. searchAndDisplayAStudent

5. displayAllstudents


After that, create an array of 5 courses in main function. Create a menu in main function to enable user to select and perform the operations we created above. Program must not exit until and unless user wants to do so.


Expert's answer

struct Course
{
public:
	void addAStudent(string sname)
	{
		students.push_back(sname);
	}
	void updateAStudent(int sID,string sname)
	{
		students[sID] = sname;
	}
	void deleteAStudent(int sID)
	{
		students.erase(students.begin() + sID);
	}
	void searchAndDisplayAStudent(int sID)
	{
		cin >> sID;
		cout << students[sID] << endl;
	}
	void displayAllstudents()
	{
		for (int i = 0; i < students.size(); i++)
		{
			cout << students[i] << endl;
		}
	}
private:
	int course_ID;
	string cousre_title;
	int credit_hrs;
	vector<string> students;
};

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS