Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ exercise /*#include Student.h *using namespace std; * EXERCISE #6 * * DO NOT USE WHILE LOOPS * * Find the Student record that matches

C++ exercise

/*#include "Student.h"

*using namespace std; * EXERCISE #6 * * DO NOT USE WHILE LOOPS * * Find the Student record that matches the given Student * and update its data. If the Student is not present, add it to the list. * * Remember that each Student has an unique identifier */ void Student::updateStudent(vector &v, Student s){

//YOUR CODE HERE

Student.h

#include #include #include

using namespace std;

enum Gender{ MALE, FEMALE };

class Student{

private: long id; // Unique ID string name; // Name of student Gender gender; // Gender of student string courseCode; // Course code (CIIC or ICOM) double gpa; // GPA of student

public: Student(long id, const string &name, Gender gender, double gpa){ this->id = id; this->name = name; this->gender = gender; this->courseCode = ""; this->gpa = gpa; }

Student(long id, const string &name, Gender gender, string courseCode, double gpa){ this->id = id; this->name = name; this->gender = gender; this->courseCode = courseCode; this->gpa = gpa; }

Student(){}

static string toString(Student& s){ string genderLetter = (s.gender == MALE ? "M" : "F"); return string("{" + to_string(s.id) + "," + s.name + "," + genderLetter + "," + to_string(s.gpa) + "}"); }

static string toString(vector& v){ string result = "{"; for (Student s : v) { result += toString(s) + ","; } result += "}"; return result; }

static string toString(vector& v){ string result = "{"; for (long id : v) { result += to_string(id) + ","; } result += "}"; return result; }

// Getters long getID(){return id;} string getName(){return name;} Gender getGender(){return gender;} double getGPA(){return gpa;} string getCourseCode(){return courseCode;}

//Setters void setName(string name){this->name = name;} void setGender(Gender gender){this->gender = gender;} void setGPA(double gpa){this->gpa = gpa;} void setCourseCode(string code){this->courseCode = code;}

// EXERCISES static double maxStudentGPA(vector& v); static double minStudentGPA(vector& v); static double averageGPA(vector &v, int N); static vector countStudents(vector& v, string code); static void removeByID(vector &v, long ID); static void updateStudent(vector &v, Student s); static vector findStudents(vector& v, float gpa); static vector repeatedStudentNames(vector& v); //BONUS };

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Guide To Client Server Databases

Authors: Joe Salemi

2nd Edition

1562763105, 978-1562763107

More Books

Students also viewed these Databases questions

Question

3. Existing organizations and programs constrain behavior.

Answered: 1 week ago