SlideShare a Scribd company logo
1 of 11
Download to read offline
#include <string>
#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>::iterator begin, vector<Student>::iterator end);
static double minStudentGPA(vector<Student>::iterator begin, vector<Student>::iterator end);
static double averageGPA(vector<Student>::iterator begin, vector<Student>::iterator end, int N);
static vector<long> countStudents(vector<Student>::iterator begin, vector<Student>::iterator
end, string code);
static vector<Student> removeByID(vector<Student>::iterator begin, vector<Student>::iterator
end, long ID);
static vector<Student> updateStudent(vector<Student>::iterator begin, vector<Student>::iterator
end, const Student &s);
static vector<Student> findStudents(vector<Student>::iterator begin, vector<Student>::iterator
end, float gpa);
static vector<Student> honorIdentifier(vector<Student>::iterator v1_begin,
vector<Student>::iterator v1_end, vector<Student>::iterator v2_begin, vector<Student>::iterator
v2_end);
};
/*
* EXERCISE: #1A
*
* Returns the highest GPA value possessed by any Student in the given list
* starting at the begin iterator up to and not including the end iterator.
*
*/
double Student::maxStudentGPA(vector<Student>::iterator begin, vector<Student>::iterator end)
{
//YOUR CODE HERE
}
/*
* EXERCISE: #1B
*
* Returns the lowest GPA value possessed by any Student in the given list.
* starting at the begin iterator up to and not including the end iterator.
*
*/
double Student::minStudentGPA(vector<Student>::iterator begin, vector<Student>::iterator end)
{
//YOUR CODE HERE
}
/*
* Exercise #1C
*
* For the first N students, calculate the average GPA
* starting at the begin iterator up to and not including the end iterator.
*
* Formula: average = sum / N
* Assume N is greater than 0
*/
double Student::averageGPA(vector<Student>::iterator begin, vector<Student>::iterator end, int
N){
//YOUR CODE HERE
}
/**
*
* EXERCISE #2
*
* Given a course code, you must return a vector that contains
* only the unique ID of the Students that have that particular course code
* starting at the begin iterator up to and not including the end iterator.
*
*/
vector<long> Student::countStudents(vector<Student>::iterator begin, vector<Student>::iterator
end, string code){
vector<long> result;
//YOUR CODE HERE
return result;
}
/*
* EXERCISE #3
*
* Return a vector that contains all the Students that have a GPA greater
* or equal to the GPA passed as the parameter
* starting at the begin iterator up to and not including the end iterator.
*
* Assume the list contains at least one such element
*/
vector<Student> Student::findStudents(vector<Student>::iterator begin,
vector<Student>::iterator end, float gpa){
vector<Student> result;
//YOU CODE HERE
return result;
}
/*
* EXERCISE: #4
*
* Return a new vector that has the same elements as the original vector
* starting at the begin iterator up to and not including the end iterator.
* but with the Student of the given ID removed.
*
*/
vector<Student> Student::removeByID(vector<Student>::iterator begin,
vector<Student>::iterator end, long ID){
vector<Student> result;
//YOUR CODE HERE
return result;
}
/*
* EXERCISE #5
*
* Return a new vector that has the same elements as the original vector
* starting at the begin iterator up to and not including the end iterator,
* but with the given Student's data updated. If the Student is not present,
* add it to the list.
*
* Remember that each Student has an unique identifier
*/
vector<Student> Student::updateStudent(vector<Student>::iterator begin,
vector<Student>::iterator end, const Student &s){
vector<Student> result;
// YOUR CODE HERE
}
/*
* BONUS EXERCISE
*
* Find the Students in both vectors that qualify to be a part of the honor roll
* starting at the begin iterator up to and not including the end iterator.
* Students may only qualify to be part of the honor roll if they have a GPA of 3.5 or higher.
*
* You may only make use of a single loop, but you may assume that both vectors have equal
length.
*
*/
vector<Student> Student::honorIdentifier(vector<Student>::iterator v1_begin,
vector<Student>::iterator v1_end, vector<Student>::iterator v2_begin, vector<Student>::iterator
v2_end){
vector<Student> result;
// YOUR CODE HERE
return result;
}
int main() {
Student s1(0, "Bienve", MALE, 3.0);
Student s2(1, "Jose Juan", MALE, 2.8);
Student s3(2, "Ana", FEMALE, 3.5);
Student s4(3, "Ariel", FEMALE,"CIIC", 4.0);
Student s5(4, "Mulan", FEMALE, "ICOM", 3.56);
Student s6(5, "Aladdin", MALE, "CIIC", 3.1);
vector<Student> testVector1{s1, s2, s3};
vector<Student> testVector2{s4, s5, s6};
auto t1Begin = testVector1.begin();
auto t1End = testVector1.end();
auto t2Begin = testVector2.begin();
auto t2End = testVector2.end();
cout << "---------TESTS---------" << endl;
cout << "n----Exercise #1A----" << endl;
cout << "Maximum GPA of testVector1: " << Student::maxStudentGPA(t1Begin, t1End) <<
endl;
cout << "n----Exercise #1B----" << endl;
cout << "Minimum GPA: " << Student::minStudentGPA(t1Begin, t1End) << endl;
cout << "n----Exercise #1C----" << endl;
cout << "Average GPA of N Students: " << Student::averageGPA(t1Begin, t1End, 2) << endl;
cout << "n----Exercise #2----" << endl;
vector<long> result = Student::countStudents(t2Begin, t2End, "ICOM");
cout << "ID of Students with code: " << Student::toString(result) << endl;
cout << "n----Exercise #3----" << endl;
vector<Student> temp = Student::findStudents(t2Begin, t2End, 3.50);
cout << "Students with a GPA of 3.5 or above: " << Student::toString(temp) << endl;
cout << "n----Exercise #4----" << endl;
cout << "Before removing ID: " << Student::toString(testVector2) << endl;
vector<Student> temp3 = Student::removeByID(t2Begin, t2End, 5l);
cout << "After removing: " << Student::toString(temp3) << endl;
cout << "n----Exercise #5----" << endl;
Student temp1(6, "Mariela", FEMALE, 2.3);
cout << "Before Updating: " << Student::toString(testVector1) << endl;
vector<Student> temp4_vec = Student::updateStudent(t1Begin, t1End, temp1);
cout << "After Updating: " << Student::toString(temp4_vec) << endl;
cout << "n-------Last Exercise-------" << endl;
vector<Student> temp2 = Student::honorIdentifier(t1Begin, t1End, t2Begin, t2End);
cout << "Students in honor roll: " << Student::toString(temp2) << endl;
}
#include -string- #include -string- #include -vector- #include -iostre (1).pdf

More Related Content

Similar to #include -string- #include -string- #include -vector- #include -iostre (1).pdf

Create a class named Student that has the following member variables.pdf
Create a class named Student that has the following member variables.pdfCreate a class named Student that has the following member variables.pdf
Create a class named Student that has the following member variables.pdfarrowvisionoptics
 
Create a Code that will add an Add, Edi, and Delete button to the GU.pdf
Create a Code that will add an Add, Edi, and Delete button to the GU.pdfCreate a Code that will add an Add, Edi, and Delete button to the GU.pdf
Create a Code that will add an Add, Edi, and Delete button to the GU.pdflakshmijewellery
 
DEBUG3 This program creates student objects and overl.pdf
DEBUG3 This program creates student objects and overl.pdfDEBUG3 This program creates student objects and overl.pdf
DEBUG3 This program creates student objects and overl.pdfmotilajain
 
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
 
Program.cs class Program { static void Main(string[] args).pdf
Program.cs class Program { static void Main(string[] args).pdfProgram.cs class Program { static void Main(string[] args).pdf
Program.cs class Program { static void Main(string[] args).pdfanandshingavi23
 
Using c++Im also using a the ide editor called CodeLiteThe hea.pdf
Using c++Im also using a the ide editor called CodeLiteThe hea.pdfUsing c++Im also using a the ide editor called CodeLiteThe hea.pdf
Using c++Im also using a the ide editor called CodeLiteThe hea.pdffashiongallery1
 
29. Code an application program that keeps track of student informat.pdf
29. Code an application program that keeps track of student informat.pdf29. Code an application program that keeps track of student informat.pdf
29. Code an application program that keeps track of student informat.pdfarishaenterprises12
 
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
 
#include iostream #include string using namespace std;int .docx
#include iostream #include string using namespace std;int .docx#include iostream #include string using namespace std;int .docx
#include iostream #include string using namespace std;int .docxajoy21
 
#include stdafx.h#include iostream#include string#incl.pdf
#include stdafx.h#include iostream#include string#incl.pdf#include stdafx.h#include iostream#include string#incl.pdf
#include stdafx.h#include iostream#include string#incl.pdfanonamobilesp
 
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
 

Similar to #include -string- #include -string- #include -vector- #include -iostre (1).pdf (17)

LAB 2 Report.docx
LAB 2 Report.docxLAB 2 Report.docx
LAB 2 Report.docx
 
Create a class named Student that has the following member variables.pdf
Create a class named Student that has the following member variables.pdfCreate a class named Student that has the following member variables.pdf
Create a class named Student that has the following member variables.pdf
 
Create a Code that will add an Add, Edi, and Delete button to the GU.pdf
Create a Code that will add an Add, Edi, and Delete button to the GU.pdfCreate a Code that will add an Add, Edi, and Delete button to the GU.pdf
Create a Code that will add an Add, Edi, and Delete button to the GU.pdf
 
DEBUG3 This program creates student objects and overl.pdf
DEBUG3 This program creates student objects and overl.pdfDEBUG3 This program creates student objects and overl.pdf
DEBUG3 This program creates student objects and overl.pdf
 
OOP Lab Report.docx
OOP Lab Report.docxOOP Lab Report.docx
OOP Lab Report.docx
 
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
 
Program.cs class Program { static void Main(string[] args).pdf
Program.cs class Program { static void Main(string[] args).pdfProgram.cs class Program { static void Main(string[] args).pdf
Program.cs class Program { static void Main(string[] args).pdf
 
Using c++Im also using a the ide editor called CodeLiteThe hea.pdf
Using c++Im also using a the ide editor called CodeLiteThe hea.pdfUsing c++Im also using a the ide editor called CodeLiteThe hea.pdf
Using c++Im also using a the ide editor called CodeLiteThe hea.pdf
 
29. Code an application program that keeps track of student informat.pdf
29. Code an application program that keeps track of student informat.pdf29. Code an application program that keeps track of student informat.pdf
29. Code an application program that keeps track of student informat.pdf
 
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
 
#include iostream #include string using namespace std;int .docx
#include iostream #include string using namespace std;int .docx#include iostream #include string using namespace std;int .docx
#include iostream #include string using namespace std;int .docx
 
#include stdafx.h#include iostream#include string#incl.pdf
#include stdafx.h#include iostream#include string#incl.pdf#include stdafx.h#include iostream#include string#incl.pdf
#include stdafx.h#include iostream#include string#incl.pdf
 
Codes on structures
Codes on structuresCodes on structures
Codes on structures
 
Unit-3 Practice Programs-5.docx
Unit-3 Practice Programs-5.docxUnit-3 Practice Programs-5.docx
Unit-3 Practice Programs-5.docx
 
Computer programming 2 -lesson 4
Computer programming 2  -lesson 4Computer programming 2  -lesson 4
Computer programming 2 -lesson 4
 
CSNB244 Lab5
CSNB244 Lab5CSNB244 Lab5
CSNB244 Lab5
 
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
 

More from ashiyanabakersandcon

You are given the null and alternative hypotheses shown below- H0--200.pdf
You are given the null and alternative hypotheses shown below- H0--200.pdfYou are given the null and alternative hypotheses shown below- H0--200.pdf
You are given the null and alternative hypotheses shown below- H0--200.pdfashiyanabakersandcon
 
Which one of the following is a combination of a disease- it's pathoge.pdf
Which one of the following is a combination of a disease- it's pathoge.pdfWhich one of the following is a combination of a disease- it's pathoge.pdf
Which one of the following is a combination of a disease- it's pathoge.pdfashiyanabakersandcon
 
Which of the following is NOT a training design activity- Decide how t.pdf
Which of the following is NOT a training design activity- Decide how t.pdfWhich of the following is NOT a training design activity- Decide how t.pdf
Which of the following is NOT a training design activity- Decide how t.pdfashiyanabakersandcon
 
What is true about the mutations within a complementation group- A The.pdf
What is true about the mutations within a complementation group- A The.pdfWhat is true about the mutations within a complementation group- A The.pdf
What is true about the mutations within a complementation group- A The.pdfashiyanabakersandcon
 
What is the major difference between CH- 2 and CH-3 in consolidation-.pdf
What is the major difference between CH- 2 and CH-3 in consolidation-.pdfWhat is the major difference between CH- 2 and CH-3 in consolidation-.pdf
What is the major difference between CH- 2 and CH-3 in consolidation-.pdfashiyanabakersandcon
 
Which of the following does NOT describe a step in the IASB's standard.pdf
Which of the following does NOT describe a step in the IASB's standard.pdfWhich of the following does NOT describe a step in the IASB's standard.pdf
Which of the following does NOT describe a step in the IASB's standard.pdfashiyanabakersandcon
 
What are the independent and dependent variables- Are there any levels.pdf
What are the independent and dependent variables- Are there any levels.pdfWhat are the independent and dependent variables- Are there any levels.pdf
What are the independent and dependent variables- Are there any levels.pdfashiyanabakersandcon
 
Urgent solution pls- b) Suppose you know that is an integer- It can b.pdf
Urgent solution pls- b) Suppose you know that  is an integer- It can b.pdfUrgent solution pls- b) Suppose you know that  is an integer- It can b.pdf
Urgent solution pls- b) Suppose you know that is an integer- It can b.pdfashiyanabakersandcon
 
Use the amortization table to determine how much of the 2nd payment is.pdf
Use the amortization table to determine how much of the 2nd payment is.pdfUse the amortization table to determine how much of the 2nd payment is.pdf
Use the amortization table to determine how much of the 2nd payment is.pdfashiyanabakersandcon
 
The velocity of money is best understood as- The rate at which a unit.pdf
The velocity of money is best understood as- The rate at which a unit.pdfThe velocity of money is best understood as- The rate at which a unit.pdf
The velocity of money is best understood as- The rate at which a unit.pdfashiyanabakersandcon
 
The five number summary of a dataset was found to be- 46-51-61-64-70 A.pdf
The five number summary of a dataset was found to be- 46-51-61-64-70 A.pdfThe five number summary of a dataset was found to be- 46-51-61-64-70 A.pdf
The five number summary of a dataset was found to be- 46-51-61-64-70 A.pdfashiyanabakersandcon
 
The images below are examples of the three general types of geologic s.pdf
The images below are examples of the three general types of geologic s.pdfThe images below are examples of the three general types of geologic s.pdf
The images below are examples of the three general types of geologic s.pdfashiyanabakersandcon
 
Squid have been used for research on nerve impulses- The mechanism of.pdf
Squid have been used for research on nerve impulses- The mechanism of.pdfSquid have been used for research on nerve impulses- The mechanism of.pdf
Squid have been used for research on nerve impulses- The mechanism of.pdfashiyanabakersandcon
 
show steps and give explanations please Hannah- age 70 and single- is.pdf
show steps and give explanations please  Hannah- age 70 and single- is.pdfshow steps and give explanations please  Hannah- age 70 and single- is.pdf
show steps and give explanations please Hannah- age 70 and single- is.pdfashiyanabakersandcon
 
Question 4 (1 point) Which of the following statements is-are wrong.pdf
Question 4 (1 point)   Which of the following statements is-are wrong.pdfQuestion 4 (1 point)   Which of the following statements is-are wrong.pdf
Question 4 (1 point) Which of the following statements is-are wrong.pdfashiyanabakersandcon
 
Program in Java Insert the missing parts to the following statement- S.pdf
Program in Java Insert the missing parts to the following statement- S.pdfProgram in Java Insert the missing parts to the following statement- S.pdf
Program in Java Insert the missing parts to the following statement- S.pdfashiyanabakersandcon
 
Explain the differential nature of MacConkey's Agar- Differential medi.pdf
Explain the differential nature of MacConkey's Agar- Differential medi.pdfExplain the differential nature of MacConkey's Agar- Differential medi.pdf
Explain the differential nature of MacConkey's Agar- Differential medi.pdfashiyanabakersandcon
 
Problem -#3 (8 points) Consider two firms Smith and Jones that are ide.pdf
Problem -#3 (8 points) Consider two firms Smith and Jones that are ide.pdfProblem -#3 (8 points) Consider two firms Smith and Jones that are ide.pdf
Problem -#3 (8 points) Consider two firms Smith and Jones that are ide.pdfashiyanabakersandcon
 
doesnt intrest get compounded yearly- Exercise 1 (20 points) What is.pdf
doesnt intrest get compounded yearly-   Exercise 1 (20 points) What is.pdfdoesnt intrest get compounded yearly-   Exercise 1 (20 points) What is.pdf
doesnt intrest get compounded yearly- Exercise 1 (20 points) What is.pdfashiyanabakersandcon
 
please answer asap Given the following situations- which type of comm.pdf
please answer asap  Given the following situations- which type of comm.pdfplease answer asap  Given the following situations- which type of comm.pdf
please answer asap Given the following situations- which type of comm.pdfashiyanabakersandcon
 

More from ashiyanabakersandcon (20)

You are given the null and alternative hypotheses shown below- H0--200.pdf
You are given the null and alternative hypotheses shown below- H0--200.pdfYou are given the null and alternative hypotheses shown below- H0--200.pdf
You are given the null and alternative hypotheses shown below- H0--200.pdf
 
Which one of the following is a combination of a disease- it's pathoge.pdf
Which one of the following is a combination of a disease- it's pathoge.pdfWhich one of the following is a combination of a disease- it's pathoge.pdf
Which one of the following is a combination of a disease- it's pathoge.pdf
 
Which of the following is NOT a training design activity- Decide how t.pdf
Which of the following is NOT a training design activity- Decide how t.pdfWhich of the following is NOT a training design activity- Decide how t.pdf
Which of the following is NOT a training design activity- Decide how t.pdf
 
What is true about the mutations within a complementation group- A The.pdf
What is true about the mutations within a complementation group- A The.pdfWhat is true about the mutations within a complementation group- A The.pdf
What is true about the mutations within a complementation group- A The.pdf
 
What is the major difference between CH- 2 and CH-3 in consolidation-.pdf
What is the major difference between CH- 2 and CH-3 in consolidation-.pdfWhat is the major difference between CH- 2 and CH-3 in consolidation-.pdf
What is the major difference between CH- 2 and CH-3 in consolidation-.pdf
 
Which of the following does NOT describe a step in the IASB's standard.pdf
Which of the following does NOT describe a step in the IASB's standard.pdfWhich of the following does NOT describe a step in the IASB's standard.pdf
Which of the following does NOT describe a step in the IASB's standard.pdf
 
What are the independent and dependent variables- Are there any levels.pdf
What are the independent and dependent variables- Are there any levels.pdfWhat are the independent and dependent variables- Are there any levels.pdf
What are the independent and dependent variables- Are there any levels.pdf
 
Urgent solution pls- b) Suppose you know that is an integer- It can b.pdf
Urgent solution pls- b) Suppose you know that  is an integer- It can b.pdfUrgent solution pls- b) Suppose you know that  is an integer- It can b.pdf
Urgent solution pls- b) Suppose you know that is an integer- It can b.pdf
 
Use the amortization table to determine how much of the 2nd payment is.pdf
Use the amortization table to determine how much of the 2nd payment is.pdfUse the amortization table to determine how much of the 2nd payment is.pdf
Use the amortization table to determine how much of the 2nd payment is.pdf
 
The velocity of money is best understood as- The rate at which a unit.pdf
The velocity of money is best understood as- The rate at which a unit.pdfThe velocity of money is best understood as- The rate at which a unit.pdf
The velocity of money is best understood as- The rate at which a unit.pdf
 
The five number summary of a dataset was found to be- 46-51-61-64-70 A.pdf
The five number summary of a dataset was found to be- 46-51-61-64-70 A.pdfThe five number summary of a dataset was found to be- 46-51-61-64-70 A.pdf
The five number summary of a dataset was found to be- 46-51-61-64-70 A.pdf
 
The images below are examples of the three general types of geologic s.pdf
The images below are examples of the three general types of geologic s.pdfThe images below are examples of the three general types of geologic s.pdf
The images below are examples of the three general types of geologic s.pdf
 
Squid have been used for research on nerve impulses- The mechanism of.pdf
Squid have been used for research on nerve impulses- The mechanism of.pdfSquid have been used for research on nerve impulses- The mechanism of.pdf
Squid have been used for research on nerve impulses- The mechanism of.pdf
 
show steps and give explanations please Hannah- age 70 and single- is.pdf
show steps and give explanations please  Hannah- age 70 and single- is.pdfshow steps and give explanations please  Hannah- age 70 and single- is.pdf
show steps and give explanations please Hannah- age 70 and single- is.pdf
 
Question 4 (1 point) Which of the following statements is-are wrong.pdf
Question 4 (1 point)   Which of the following statements is-are wrong.pdfQuestion 4 (1 point)   Which of the following statements is-are wrong.pdf
Question 4 (1 point) Which of the following statements is-are wrong.pdf
 
Program in Java Insert the missing parts to the following statement- S.pdf
Program in Java Insert the missing parts to the following statement- S.pdfProgram in Java Insert the missing parts to the following statement- S.pdf
Program in Java Insert the missing parts to the following statement- S.pdf
 
Explain the differential nature of MacConkey's Agar- Differential medi.pdf
Explain the differential nature of MacConkey's Agar- Differential medi.pdfExplain the differential nature of MacConkey's Agar- Differential medi.pdf
Explain the differential nature of MacConkey's Agar- Differential medi.pdf
 
Problem -#3 (8 points) Consider two firms Smith and Jones that are ide.pdf
Problem -#3 (8 points) Consider two firms Smith and Jones that are ide.pdfProblem -#3 (8 points) Consider two firms Smith and Jones that are ide.pdf
Problem -#3 (8 points) Consider two firms Smith and Jones that are ide.pdf
 
doesnt intrest get compounded yearly- Exercise 1 (20 points) What is.pdf
doesnt intrest get compounded yearly-   Exercise 1 (20 points) What is.pdfdoesnt intrest get compounded yearly-   Exercise 1 (20 points) What is.pdf
doesnt intrest get compounded yearly- Exercise 1 (20 points) What is.pdf
 
please answer asap Given the following situations- which type of comm.pdf
please answer asap  Given the following situations- which type of comm.pdfplease answer asap  Given the following situations- which type of comm.pdf
please answer asap Given the following situations- which type of comm.pdf
 

Recently uploaded

Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaEADTU
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024Borja Sotomayor
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesPooky Knightsmith
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnershipsexpandedwebsite
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint23600690
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17Celine George
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...EduSkills OECD
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppCeline George
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptxPoojaSen20
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptxPoojaSen20
 

Recently uploaded (20)

Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 

#include -string- #include -string- #include -vector- #include -iostre (1).pdf

  • 1. #include <string> #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;
  • 2. } 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 = "{";
  • 3. 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>::iterator begin, vector<Student>::iterator end); static double minStudentGPA(vector<Student>::iterator begin, vector<Student>::iterator end); static double averageGPA(vector<Student>::iterator begin, vector<Student>::iterator end, int N); static vector<long> countStudents(vector<Student>::iterator begin, vector<Student>::iterator end, string code);
  • 4. static vector<Student> removeByID(vector<Student>::iterator begin, vector<Student>::iterator end, long ID); static vector<Student> updateStudent(vector<Student>::iterator begin, vector<Student>::iterator end, const Student &s); static vector<Student> findStudents(vector<Student>::iterator begin, vector<Student>::iterator end, float gpa); static vector<Student> honorIdentifier(vector<Student>::iterator v1_begin, vector<Student>::iterator v1_end, vector<Student>::iterator v2_begin, vector<Student>::iterator v2_end); }; /* * EXERCISE: #1A * * Returns the highest GPA value possessed by any Student in the given list * starting at the begin iterator up to and not including the end iterator. * */ double Student::maxStudentGPA(vector<Student>::iterator begin, vector<Student>::iterator end) { //YOUR CODE HERE } /* * EXERCISE: #1B * * Returns the lowest GPA value possessed by any Student in the given list.
  • 5. * starting at the begin iterator up to and not including the end iterator. * */ double Student::minStudentGPA(vector<Student>::iterator begin, vector<Student>::iterator end) { //YOUR CODE HERE } /* * Exercise #1C * * For the first N students, calculate the average GPA * starting at the begin iterator up to and not including the end iterator. * * Formula: average = sum / N * Assume N is greater than 0 */ double Student::averageGPA(vector<Student>::iterator begin, vector<Student>::iterator end, int N){ //YOUR CODE HERE } /** * * EXERCISE #2 *
  • 6. * Given a course code, you must return a vector that contains * only the unique ID of the Students that have that particular course code * starting at the begin iterator up to and not including the end iterator. * */ vector<long> Student::countStudents(vector<Student>::iterator begin, vector<Student>::iterator end, string code){ vector<long> result; //YOUR CODE HERE return result; } /* * EXERCISE #3 * * Return a vector that contains all the Students that have a GPA greater * or equal to the GPA passed as the parameter * starting at the begin iterator up to and not including the end iterator. * * Assume the list contains at least one such element */ vector<Student> Student::findStudents(vector<Student>::iterator begin, vector<Student>::iterator end, float gpa){ vector<Student> result; //YOU CODE HERE
  • 7. return result; } /* * EXERCISE: #4 * * Return a new vector that has the same elements as the original vector * starting at the begin iterator up to and not including the end iterator. * but with the Student of the given ID removed. * */ vector<Student> Student::removeByID(vector<Student>::iterator begin, vector<Student>::iterator end, long ID){ vector<Student> result; //YOUR CODE HERE return result; } /* * EXERCISE #5 * * Return a new vector that has the same elements as the original vector * starting at the begin iterator up to and not including the end iterator, * but with the given Student's data updated. If the Student is not present, * add it to the list. *
  • 8. * Remember that each Student has an unique identifier */ vector<Student> Student::updateStudent(vector<Student>::iterator begin, vector<Student>::iterator end, const Student &s){ vector<Student> result; // YOUR CODE HERE } /* * BONUS EXERCISE * * Find the Students in both vectors that qualify to be a part of the honor roll * starting at the begin iterator up to and not including the end iterator. * Students may only qualify to be part of the honor roll if they have a GPA of 3.5 or higher. * * You may only make use of a single loop, but you may assume that both vectors have equal length. * */ vector<Student> Student::honorIdentifier(vector<Student>::iterator v1_begin, vector<Student>::iterator v1_end, vector<Student>::iterator v2_begin, vector<Student>::iterator v2_end){ vector<Student> result; // YOUR CODE HERE return result; }
  • 9. int main() { Student s1(0, "Bienve", MALE, 3.0); Student s2(1, "Jose Juan", MALE, 2.8); Student s3(2, "Ana", FEMALE, 3.5); Student s4(3, "Ariel", FEMALE,"CIIC", 4.0); Student s5(4, "Mulan", FEMALE, "ICOM", 3.56); Student s6(5, "Aladdin", MALE, "CIIC", 3.1); vector<Student> testVector1{s1, s2, s3}; vector<Student> testVector2{s4, s5, s6}; auto t1Begin = testVector1.begin(); auto t1End = testVector1.end(); auto t2Begin = testVector2.begin(); auto t2End = testVector2.end(); cout << "---------TESTS---------" << endl; cout << "n----Exercise #1A----" << endl; cout << "Maximum GPA of testVector1: " << Student::maxStudentGPA(t1Begin, t1End) << endl; cout << "n----Exercise #1B----" << endl; cout << "Minimum GPA: " << Student::minStudentGPA(t1Begin, t1End) << endl; cout << "n----Exercise #1C----" << endl; cout << "Average GPA of N Students: " << Student::averageGPA(t1Begin, t1End, 2) << endl; cout << "n----Exercise #2----" << endl;
  • 10. vector<long> result = Student::countStudents(t2Begin, t2End, "ICOM"); cout << "ID of Students with code: " << Student::toString(result) << endl; cout << "n----Exercise #3----" << endl; vector<Student> temp = Student::findStudents(t2Begin, t2End, 3.50); cout << "Students with a GPA of 3.5 or above: " << Student::toString(temp) << endl; cout << "n----Exercise #4----" << endl; cout << "Before removing ID: " << Student::toString(testVector2) << endl; vector<Student> temp3 = Student::removeByID(t2Begin, t2End, 5l); cout << "After removing: " << Student::toString(temp3) << endl; cout << "n----Exercise #5----" << endl; Student temp1(6, "Mariela", FEMALE, 2.3); cout << "Before Updating: " << Student::toString(testVector1) << endl; vector<Student> temp4_vec = Student::updateStudent(t1Begin, t1End, temp1); cout << "After Updating: " << Student::toString(temp4_vec) << endl; cout << "n-------Last Exercise-------" << endl; vector<Student> temp2 = Student::honorIdentifier(t1Begin, t1End, t2Begin, t2End); cout << "Students in honor roll: " << Student::toString(temp2) << endl; }