SlideShare a Scribd company logo
1 of 9
Download to read offline
Header
#include <string>
#include <vector>
#include <iostream>
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<Student>& v){
string result = "{";
for (Student s : v) {
result += toString(s) + ",";
}
result += "}";
return result;
}
static string toString(vector<long>& v){
string result = "{";
for (long id : v) {
result += to_string(id) + ",";
}
result += "}";
return result;
}
// Getters
long getID() const {return id;}
string getName() const {return name;}
Gender getGender() const {return gender;}
double getGPA() const {return gpa;}
string getCourseCode() const {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<Student>& v);
static double minStudentGPA(vector<Student>& v);
static double averageGPA(vector<Student> &v, int N);
static vector<long> countStudents(vector<Student>& v, string code);
static void removeByID(vector<Student> &v, long ID);
static void updateStudent(vector<Student> &v, const Student &s);
static vector<Student> findStudents(vector<Student>& v, float gpa);
static vector<Student> repeatedStudentNames(vector<Student>& v);
};
Cpp file
#include "Student.h"
using namespace std;
/*
* EXERCISE: #1A
*
* IMPLEMENT USING AN ENHANCED FOR LOOP (ForEach).
*
* Returns the highest GPA value possessed by any Student in the given list.
*
*/
double Student::maxStudentGPA(vector<Student>& v)
{
//YOUR CODE HERE
return -99.9; //DUMMY RETURN
}
/*
* EXERCISE: #1B
*
* IMPLEMENT USING A REGULAR FOR LOOP.
*
* Returns the lowest GPA value possessed by any Student in the given list.
*
*/
double Student::minStudentGPA(vector<Student>& v)
{
//YOUR CODE HERE
return -99.9; //DUMMY RETURN
}
/*
* Exercise #1C
*
* IMPLEMENT USING A WHILE LOOP
*
* For the first N students, calculate the average gpa
*
* Formula: average = sum / N
* Assume N is greater than 0
*/
double Student::averageGPA(vector<Student> &v, int N){
//YOUR CODE HERE
return -99.9; //DUMMY RETURN
}
/**
*
* EXERCISE #2
*
* IMPLEMENT IT USING AN ENHANCED FOR LOOP (ForEach)
*
* Given a course code, you must return a vector that contains
* only the unique ID of the Students that have that particular course code.
*/
vector<long> Student::countStudents(vector<Student>& v, string code){
vector<long> result;
//YOUR CODE HERE
return result;
}
/*
* EXERCISE #3
*
* IMPLEMENT USING A DO...WHILE LOOP
*
* Return a vector that contains all the Students that have a GPA greater
* or equal to the GPA passed as the parameter
*
* Assume the list contains at least one element
*/
vector<Student> Student::findStudents(vector<Student>& v, float gpa){
//YOU CODE HERE
return v;
}
/*
* EXERCISE: #4
*
* IMPLEMENT WITH ANY LOOP
*
* Removes the first occurrence of the specified Student ID,
* if it is present. If not present, then list is unchanged.
*
* HINT: Verify the methods erase() and begin() of the vector
*/
void Student::removeByID(vector<Student> &v, long ID){
//YOUR CODE HERE
}
/*
* EXERCISE #5
*
* 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<Student> &v, const Student &s){
//YOUR CODE HERE
}
/*
* BONUS
*
* IMPLEMENT WITH NESTED LOOPS USING ANY LOOP.
*
* Returns a vector cointaining two Students that has the same name.
* If there is no repeated names, the vector stays empty.
*
* HINT: Use the compare method of the string library
*/
vector<Student> Student::repeatedStudentNames(vector<Student>& v){
//YOUR CODE HERE
return v;
}

More Related Content

Similar to Header #include -string- #include -vector- #include -iostream- using.pdf

Starting with Main.java, where I tested everythingimport College..pdf
Starting with Main.java, where I tested everythingimport College..pdfStarting with Main.java, where I tested everythingimport College..pdf
Starting with Main.java, where I tested everythingimport College..pdfaptind
 
public class Person { private String name; private int age;.pdf
public class Person { private String name; private int age;.pdfpublic class Person { private String name; private int age;.pdf
public class Person { private String name; private int age;.pdfarjuncp10
 
Answer using basic programming beginner knowledge pls...........Othe.pdf
Answer using basic programming beginner knowledge pls...........Othe.pdfAnswer using basic programming beginner knowledge pls...........Othe.pdf
Answer using basic programming beginner knowledge pls...........Othe.pdfsuresh640714
 
Hello. Im currently working on the last section to my assignment a.pdf
Hello. Im currently working on the last section to my assignment a.pdfHello. Im currently working on the last section to my assignment a.pdf
Hello. Im currently working on the last section to my assignment a.pdfirshadkumar3
 
Program: Inheritance in Class - to find topper out of 10 students
Program: Inheritance in Class - to find topper out of 10 studentsProgram: Inheritance in Class - to find topper out of 10 students
Program: Inheritance in Class - to find topper out of 10 studentsSwarup Boro
 
In Java- Create a Graduate class derived from Student- A graduate has.pdf
In Java- Create a Graduate class derived from Student- A graduate has.pdfIn Java- Create a Graduate class derived from Student- A graduate has.pdf
In Java- Create a Graduate class derived from Student- A graduate has.pdfStewart29UReesa
 
Programming in C#Define an application to include classes for Stud.pdf
Programming in C#Define an application to include classes for Stud.pdfProgramming in C#Define an application to include classes for Stud.pdf
Programming in C#Define an application to include classes for Stud.pdffashionscollect
 
Schema Refinement And Normal Forms Changes That Occurred Since.pdf
Schema Refinement And Normal Forms Changes That Occurred Since.pdfSchema Refinement And Normal Forms Changes That Occurred Since.pdf
Schema Refinement And Normal Forms Changes That Occurred Since.pdfsdfghj21
 
How to implement g rpc services in nodejs
How to implement g rpc services in nodejsHow to implement g rpc services in nodejs
How to implement g rpc services in nodejsKaty Slemon
 

Similar to Header #include -string- #include -vector- #include -iostream- using.pdf (12)

Starting with Main.java, where I tested everythingimport College..pdf
Starting with Main.java, where I tested everythingimport College..pdfStarting with Main.java, where I tested everythingimport College..pdf
Starting with Main.java, where I tested everythingimport College..pdf
 
public class Person { private String name; private int age;.pdf
public class Person { private String name; private int age;.pdfpublic class Person { private String name; private int age;.pdf
public class Person { private String name; private int age;.pdf
 
Answer using basic programming beginner knowledge pls...........Othe.pdf
Answer using basic programming beginner knowledge pls...........Othe.pdfAnswer using basic programming beginner knowledge pls...........Othe.pdf
Answer using basic programming beginner knowledge pls...........Othe.pdf
 
OOP Lab Report.docx
OOP Lab Report.docxOOP Lab Report.docx
OOP Lab Report.docx
 
Hello. Im currently working on the last section to my assignment a.pdf
Hello. Im currently working on the last section to my assignment a.pdfHello. Im currently working on the last section to my assignment a.pdf
Hello. Im currently working on the last section to my assignment a.pdf
 
Program: Inheritance in Class - to find topper out of 10 students
Program: Inheritance in Class - to find topper out of 10 studentsProgram: Inheritance in Class - to find topper out of 10 students
Program: Inheritance in Class - to find topper out of 10 students
 
In Java- Create a Graduate class derived from Student- A graduate has.pdf
In Java- Create a Graduate class derived from Student- A graduate has.pdfIn Java- Create a Graduate class derived from Student- A graduate has.pdf
In Java- Create a Graduate class derived from Student- A graduate has.pdf
 
Computer programming 2 -lesson 4
Computer programming 2  -lesson 4Computer programming 2  -lesson 4
Computer programming 2 -lesson 4
 
Programming in C#Define an application to include classes for Stud.pdf
Programming in C#Define an application to include classes for Stud.pdfProgramming in C#Define an application to include classes for Stud.pdf
Programming in C#Define an application to include classes for Stud.pdf
 
Schema Refinement And Normal Forms Changes That Occurred Since.pdf
Schema Refinement And Normal Forms Changes That Occurred Since.pdfSchema Refinement And Normal Forms Changes That Occurred Since.pdf
Schema Refinement And Normal Forms Changes That Occurred Since.pdf
 
How to implement g rpc services in nodejs
How to implement g rpc services in nodejsHow to implement g rpc services in nodejs
How to implement g rpc services in nodejs
 
1 plsql introduction1
1 plsql introduction11 plsql introduction1
1 plsql introduction1
 

More from gaurav444u

Health Care Unions Find a Voice as the Pandemic Rages - The New York T.pdf
Health Care Unions Find a Voice as the Pandemic Rages - The New York T.pdfHealth Care Unions Find a Voice as the Pandemic Rages - The New York T.pdf
Health Care Unions Find a Voice as the Pandemic Rages - The New York T.pdfgaurav444u
 
Health - Related Questions 1- What three pieces of information are gat.pdf
Health - Related Questions 1- What three pieces of information are gat.pdfHealth - Related Questions 1- What three pieces of information are gat.pdf
Health - Related Questions 1- What three pieces of information are gat.pdfgaurav444u
 
Health Information Technology (HIT) as Electronic Health Record (EHR).pdf
Health Information Technology (HIT) as Electronic Health Record (EHR).pdfHealth Information Technology (HIT) as Electronic Health Record (EHR).pdf
Health Information Technology (HIT) as Electronic Health Record (EHR).pdfgaurav444u
 
Headlands Limited has the following information available regarding it.pdf
Headlands Limited has the following information available regarding it.pdfHeadlands Limited has the following information available regarding it.pdf
Headlands Limited has the following information available regarding it.pdfgaurav444u
 
he method by which glucose is transported into a cell depends on the m.pdf
he method by which glucose is transported into a cell depends on the m.pdfhe method by which glucose is transported into a cell depends on the m.pdf
he method by which glucose is transported into a cell depends on the m.pdfgaurav444u
 
he City Council of Inman Village approved a budget with estimated reve.pdf
he City Council of Inman Village approved a budget with estimated reve.pdfhe City Council of Inman Village approved a budget with estimated reve.pdf
he City Council of Inman Village approved a budget with estimated reve.pdfgaurav444u
 
he department has expanded telehealth and device-monitoring services-.pdf
he department has expanded telehealth and device-monitoring services-.pdfhe department has expanded telehealth and device-monitoring services-.pdf
he department has expanded telehealth and device-monitoring services-.pdfgaurav444u
 
he evolution of eukaryotic cells most likely occurred in many steps- O.pdf
he evolution of eukaryotic cells most likely occurred in many steps- O.pdfhe evolution of eukaryotic cells most likely occurred in many steps- O.pdf
he evolution of eukaryotic cells most likely occurred in many steps- O.pdfgaurav444u
 
Having passed your board exam- you are now qualified to work in the pa.pdf
Having passed your board exam- you are now qualified to work in the pa.pdfHaving passed your board exam- you are now qualified to work in the pa.pdf
Having passed your board exam- you are now qualified to work in the pa.pdfgaurav444u
 
Having been lost in the desert for 2 days without water- Marion is bad.pdf
Having been lost in the desert for 2 days without water- Marion is bad.pdfHaving been lost in the desert for 2 days without water- Marion is bad.pdf
Having been lost in the desert for 2 days without water- Marion is bad.pdfgaurav444u
 
Harvard Case Study- Humana's Bold Goal- 20 Percent Healthier by 2020 -.pdf
Harvard Case Study- Humana's Bold Goal- 20 Percent Healthier by 2020 -.pdfHarvard Case Study- Humana's Bold Goal- 20 Percent Healthier by 2020 -.pdf
Harvard Case Study- Humana's Bold Goal- 20 Percent Healthier by 2020 -.pdfgaurav444u
 
Harry climbed a ladder to trim some trees- While bending too fast- he.pdf
Harry climbed a ladder to trim some trees- While bending too fast- he.pdfHarry climbed a ladder to trim some trees- While bending too fast- he.pdf
Harry climbed a ladder to trim some trees- While bending too fast- he.pdfgaurav444u
 
HELP- Add button wont work-- i would click on the button and that page.pdf
HELP- Add button wont work-- i would click on the button and that page.pdfHELP- Add button wont work-- i would click on the button and that page.pdf
HELP- Add button wont work-- i would click on the button and that page.pdfgaurav444u
 
Help with this substitution program- line 3 of the output is different.pdf
Help with this substitution program- line 3 of the output is different.pdfHelp with this substitution program- line 3 of the output is different.pdf
Help with this substitution program- line 3 of the output is different.pdfgaurav444u
 
help The following information pertains to Ming Corp- at January 1- Ye.pdf
help The following information pertains to Ming Corp- at January 1- Ye.pdfhelp The following information pertains to Ming Corp- at January 1- Ye.pdf
help The following information pertains to Ming Corp- at January 1- Ye.pdfgaurav444u
 
Help Tina identify her strengths- weaknesses- the opportunities presen.pdf
Help Tina identify her strengths- weaknesses- the opportunities presen.pdfHelp Tina identify her strengths- weaknesses- the opportunities presen.pdf
Help Tina identify her strengths- weaknesses- the opportunities presen.pdfgaurav444u
 
Harriet Quarterly wants a 14- return on the $15000 of assets she has i.pdf
Harriet Quarterly wants a 14- return on the $15000 of assets she has i.pdfHarriet Quarterly wants a 14- return on the $15000 of assets she has i.pdf
Harriet Quarterly wants a 14- return on the $15000 of assets she has i.pdfgaurav444u
 
Harriet is described as someone who -was unusual in her ability to coo.pdf
Harriet is described as someone who -was unusual in her ability to coo.pdfHarriet is described as someone who -was unusual in her ability to coo.pdf
Harriet is described as someone who -was unusual in her ability to coo.pdfgaurav444u
 
help please- thank you! i need to know the Virginia Department of Educ.pdf
help please- thank you! i need to know the Virginia Department of Educ.pdfhelp please- thank you! i need to know the Virginia Department of Educ.pdf
help please- thank you! i need to know the Virginia Department of Educ.pdfgaurav444u
 
Help please! 1- You are wanting to know how many sloths are in a pop.pdf
Help please!   1- You are wanting to know how many sloths are in a pop.pdfHelp please!   1- You are wanting to know how many sloths are in a pop.pdf
Help please! 1- You are wanting to know how many sloths are in a pop.pdfgaurav444u
 

More from gaurav444u (20)

Health Care Unions Find a Voice as the Pandemic Rages - The New York T.pdf
Health Care Unions Find a Voice as the Pandemic Rages - The New York T.pdfHealth Care Unions Find a Voice as the Pandemic Rages - The New York T.pdf
Health Care Unions Find a Voice as the Pandemic Rages - The New York T.pdf
 
Health - Related Questions 1- What three pieces of information are gat.pdf
Health - Related Questions 1- What three pieces of information are gat.pdfHealth - Related Questions 1- What three pieces of information are gat.pdf
Health - Related Questions 1- What three pieces of information are gat.pdf
 
Health Information Technology (HIT) as Electronic Health Record (EHR).pdf
Health Information Technology (HIT) as Electronic Health Record (EHR).pdfHealth Information Technology (HIT) as Electronic Health Record (EHR).pdf
Health Information Technology (HIT) as Electronic Health Record (EHR).pdf
 
Headlands Limited has the following information available regarding it.pdf
Headlands Limited has the following information available regarding it.pdfHeadlands Limited has the following information available regarding it.pdf
Headlands Limited has the following information available regarding it.pdf
 
he method by which glucose is transported into a cell depends on the m.pdf
he method by which glucose is transported into a cell depends on the m.pdfhe method by which glucose is transported into a cell depends on the m.pdf
he method by which glucose is transported into a cell depends on the m.pdf
 
he City Council of Inman Village approved a budget with estimated reve.pdf
he City Council of Inman Village approved a budget with estimated reve.pdfhe City Council of Inman Village approved a budget with estimated reve.pdf
he City Council of Inman Village approved a budget with estimated reve.pdf
 
he department has expanded telehealth and device-monitoring services-.pdf
he department has expanded telehealth and device-monitoring services-.pdfhe department has expanded telehealth and device-monitoring services-.pdf
he department has expanded telehealth and device-monitoring services-.pdf
 
he evolution of eukaryotic cells most likely occurred in many steps- O.pdf
he evolution of eukaryotic cells most likely occurred in many steps- O.pdfhe evolution of eukaryotic cells most likely occurred in many steps- O.pdf
he evolution of eukaryotic cells most likely occurred in many steps- O.pdf
 
Having passed your board exam- you are now qualified to work in the pa.pdf
Having passed your board exam- you are now qualified to work in the pa.pdfHaving passed your board exam- you are now qualified to work in the pa.pdf
Having passed your board exam- you are now qualified to work in the pa.pdf
 
Having been lost in the desert for 2 days without water- Marion is bad.pdf
Having been lost in the desert for 2 days without water- Marion is bad.pdfHaving been lost in the desert for 2 days without water- Marion is bad.pdf
Having been lost in the desert for 2 days without water- Marion is bad.pdf
 
Harvard Case Study- Humana's Bold Goal- 20 Percent Healthier by 2020 -.pdf
Harvard Case Study- Humana's Bold Goal- 20 Percent Healthier by 2020 -.pdfHarvard Case Study- Humana's Bold Goal- 20 Percent Healthier by 2020 -.pdf
Harvard Case Study- Humana's Bold Goal- 20 Percent Healthier by 2020 -.pdf
 
Harry climbed a ladder to trim some trees- While bending too fast- he.pdf
Harry climbed a ladder to trim some trees- While bending too fast- he.pdfHarry climbed a ladder to trim some trees- While bending too fast- he.pdf
Harry climbed a ladder to trim some trees- While bending too fast- he.pdf
 
HELP- Add button wont work-- i would click on the button and that page.pdf
HELP- Add button wont work-- i would click on the button and that page.pdfHELP- Add button wont work-- i would click on the button and that page.pdf
HELP- Add button wont work-- i would click on the button and that page.pdf
 
Help with this substitution program- line 3 of the output is different.pdf
Help with this substitution program- line 3 of the output is different.pdfHelp with this substitution program- line 3 of the output is different.pdf
Help with this substitution program- line 3 of the output is different.pdf
 
help The following information pertains to Ming Corp- at January 1- Ye.pdf
help The following information pertains to Ming Corp- at January 1- Ye.pdfhelp The following information pertains to Ming Corp- at January 1- Ye.pdf
help The following information pertains to Ming Corp- at January 1- Ye.pdf
 
Help Tina identify her strengths- weaknesses- the opportunities presen.pdf
Help Tina identify her strengths- weaknesses- the opportunities presen.pdfHelp Tina identify her strengths- weaknesses- the opportunities presen.pdf
Help Tina identify her strengths- weaknesses- the opportunities presen.pdf
 
Harriet Quarterly wants a 14- return on the $15000 of assets she has i.pdf
Harriet Quarterly wants a 14- return on the $15000 of assets she has i.pdfHarriet Quarterly wants a 14- return on the $15000 of assets she has i.pdf
Harriet Quarterly wants a 14- return on the $15000 of assets she has i.pdf
 
Harriet is described as someone who -was unusual in her ability to coo.pdf
Harriet is described as someone who -was unusual in her ability to coo.pdfHarriet is described as someone who -was unusual in her ability to coo.pdf
Harriet is described as someone who -was unusual in her ability to coo.pdf
 
help please- thank you! i need to know the Virginia Department of Educ.pdf
help please- thank you! i need to know the Virginia Department of Educ.pdfhelp please- thank you! i need to know the Virginia Department of Educ.pdf
help please- thank you! i need to know the Virginia Department of Educ.pdf
 
Help please! 1- You are wanting to know how many sloths are in a pop.pdf
Help please!   1- You are wanting to know how many sloths are in a pop.pdfHelp please!   1- You are wanting to know how many sloths are in a pop.pdf
Help please! 1- You are wanting to know how many sloths are in a pop.pdf
 

Recently uploaded

Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 

Recently uploaded (20)

Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 

Header #include -string- #include -vector- #include -iostream- using.pdf

  • 1. Header #include <string> #include <vector> #include <iostream> 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 = "";
  • 2. 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<Student>& v){ string result = "{"; for (Student s : v) { result += toString(s) + ","; } result += "}"; return result; } static string toString(vector<long>& v){
  • 3. string result = "{"; for (long id : v) { result += to_string(id) + ","; } result += "}"; return result; } // Getters long getID() const {return id;} string getName() const {return name;} Gender getGender() const {return gender;} double getGPA() const {return gpa;} string getCourseCode() const {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<Student>& v); static double minStudentGPA(vector<Student>& v); static double averageGPA(vector<Student> &v, int N); static vector<long> countStudents(vector<Student>& v, string code);
  • 4. static void removeByID(vector<Student> &v, long ID); static void updateStudent(vector<Student> &v, const Student &s); static vector<Student> findStudents(vector<Student>& v, float gpa); static vector<Student> repeatedStudentNames(vector<Student>& v); }; Cpp file #include "Student.h" using namespace std; /* * EXERCISE: #1A * * IMPLEMENT USING AN ENHANCED FOR LOOP (ForEach). * * Returns the highest GPA value possessed by any Student in the given list. * */ double Student::maxStudentGPA(vector<Student>& v) { //YOUR CODE HERE return -99.9; //DUMMY RETURN } /* * EXERCISE: #1B
  • 5. * * IMPLEMENT USING A REGULAR FOR LOOP. * * Returns the lowest GPA value possessed by any Student in the given list. * */ double Student::minStudentGPA(vector<Student>& v) { //YOUR CODE HERE return -99.9; //DUMMY RETURN } /* * Exercise #1C * * IMPLEMENT USING A WHILE LOOP * * For the first N students, calculate the average gpa * * Formula: average = sum / N * Assume N is greater than 0 */ double Student::averageGPA(vector<Student> &v, int N){ //YOUR CODE HERE
  • 6. return -99.9; //DUMMY RETURN } /** * * EXERCISE #2 * * IMPLEMENT IT USING AN ENHANCED FOR LOOP (ForEach) * * Given a course code, you must return a vector that contains * only the unique ID of the Students that have that particular course code. */ vector<long> Student::countStudents(vector<Student>& v, string code){ vector<long> result; //YOUR CODE HERE return result; } /* * EXERCISE #3 * * IMPLEMENT USING A DO...WHILE LOOP * * Return a vector that contains all the Students that have a GPA greater * or equal to the GPA passed as the parameter
  • 7. * * Assume the list contains at least one element */ vector<Student> Student::findStudents(vector<Student>& v, float gpa){ //YOU CODE HERE return v; } /* * EXERCISE: #4 * * IMPLEMENT WITH ANY LOOP * * Removes the first occurrence of the specified Student ID, * if it is present. If not present, then list is unchanged. * * HINT: Verify the methods erase() and begin() of the vector */ void Student::removeByID(vector<Student> &v, long ID){ //YOUR CODE HERE } /* * EXERCISE #5 *
  • 8. * 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<Student> &v, const Student &s){ //YOUR CODE HERE } /* * BONUS * * IMPLEMENT WITH NESTED LOOPS USING ANY LOOP. * * Returns a vector cointaining two Students that has the same name. * If there is no repeated names, the vector stays empty. * * HINT: Use the compare method of the string library */ vector<Student> Student::repeatedStudentNames(vector<Student>& v){ //YOUR CODE HERE return v;
  • 9. }