In this assignment, write a program using class data structure to create student
ID: 3674414 • Letter: I
Question
In this assignment, write a program using class data structure to create student records. Write a header file (h) to define class structure, a function file (cpp) to define all the functions of the class, and a main file (cpp) to use the class and its functions. The class functions should include set_records() to create new records, print_record() to print the student records, find_record() to find a record by name. The class private data should include name, gender, math score, programming score, and a vector to contain all of those data as a single record for each student.
Enter new student records (name gender math_score programming score) Mary F Jane F Jack M 96 97 96 98 97 97 2 Select the following options 1. Print all student records 2. Search student record by name 3. quit Printing student records Gender Name Mary Jane Jack math 96 97 96 prog 98 97 97 Select the following options 1. Print all student records 2. Search student record by name 3. quit 2 Enter student name for searching Jane Gender math 97 Name prog 97 Jane Select the following sub-options 1. Edit math score 2. Edit prog score 1 Enter the new score: 100Explanation / Answer
Hi, I have implemented every things, You just add extra functionality that you want to have in Student class.
//Student.h
#ifndef STUDENT_H
#define STUDENT_H
#include <string>
using namespace std;
class Student
{
private:
int ID;
string name;
double GPA;
char gender;
public:
Student();
Student(int ID, string name, double GPA, char gender);
void setStudent(int ID, string name, double GPA, char gender);
int getID();
string getName();
double getGPA();
char getGender();
void print();
};
#endif
// Student.cpp
#include "Student.h"
#include <iostream>
using namespace std;
Student :: Student()
{
ID = 0;
name = "";
GPA = 0;
gender = ' ';
}
Student :: Student(int ID, string name, double GPA, char gender)
{
this -> ID = ID;
this -> name = name;
this -> GPA = GPA;
this -> gender = gender;
}
void Student :: setStudent(int ID, string name, double GPA, char gender)
{
this -> ID = ID;
this -> name = name;
this -> GPA = GPA;
this -> gender = gender;
}
int Student :: getID()
{
return ID;
}
string Student :: getName()
{
return name;
}
double Student :: getGPA()
{
return GPA;
}
char Student :: getGender()
{
return gender;
}
void Student :: print()
{
cout << "ID : " << ID << endl;
cout << "Name : " << name << endl;
cout << "GPA : " << GPA << endl;
cout << "Gender : " << gender << endl;
}
//StudentDemo.cpp
#include <iostream>
#include "Student.h"
using namespace std;
int main()
{
Student s;
int ID;
string name;
double GPA;
char gender;
cout << "Enter ID ";
cin >> ID;
cout << "Enter name ";
cin >> name;
cout << "Enter GPA ";
cin >> GPA;
cout << "Enter gender ";
cin >> gender;
s.setStudent(ID, name, GPA, gender);
s.print();
return 0;
}