Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

//The next screenshot is the content of the students.in file CAS-California St?

ID: 3710829 • Letter: #

Question

//The next screenshot is the content of the students.in file

CAS-California St? x ? Quiz 1 Solution-F- X ? Quiz1,518-Solution D p150,S18-HW2(2).c x D csusB x-, e physics question I c x Chat with Clairehill × / D CSE 202 Apps O YouTube CAS-Calfornia StateFacebaok a Amazancom:Online Online CCompile Design class Student to contain student name and birthday. class Student private string name; string month; string day; string year; public: b: Design class Roster to contain a vector of students class Roster private public: vector

Explanation / Answer

Given below is the code for the question.
Please do rate the answer if it was helpful. Thank you


Input file : students.in
--------------
Joy Jan 2 1995
Happiness Nov 11 2000
Glee Apr 30 1999
Smile Apr 1 1997
Bliss Aug 15 2001
Delight Apr 7 2002
Char Nov 1 1997

main.cpp
-------------------
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;

class Student
{
private:
string name;
string month;
string day;
string year;
public:
Student(){}
Student(string name1, string month1, string day1, string year1)
{
name = name1;
month = month1;
day = day1;
year = year1;
}

string getName()
{
return name;
}

string getMonth()
{
return month;
}

string getDay()
{
return day;
}
string getYear()
{
return year;
}

void setName(string n)
{
name = n;
}
void setMonth(string m)
{
month = m;
}

void setDay(string d)
{
day = d;
}
void setYear(string y)
{
year = y;
}

};

class Roster
{
private:
vector<Student> students;
public:
Roster(){}
void addStudent(const Student &s)
{
students.push_back(s);
}
int getNumStudents()
{
return students.size();
}

Student getStudent(int index)
{
return students[index];
}

void printStudents(string month) //print students whose b'day is in specified month
{
cout << "Students with birthday in the month " << month << endl;
for(int i = 0; i < students.size(); i++)
{
if(students[i].getMonth() == month)
cout << students[i].getName() << " "
<< students[i].getMonth() << " " << students[i].getDay() << " "
<< students[i].getYear() << endl;
}
cout << "===========" << endl;
}
};

int main()
{
string filename;
ifstream infile;

cout << "Enter input filename: ";
cin >> filename;

infile.open(filename.c_str());
if(infile.fail())
{
cout << "ERROR: could not open input file " << filename << endl;
return 1;
}

string name, month, day, year;
Student s;
Roster roster;

while(infile >> name)
{
infile >> month >> day >> year;
s.setName(name);
s.setMonth(month);
s.setDay(day);
s.setYear(year);
roster.addStudent(s);
}
infile.close();

roster.printStudents("Apr");
}


-------------

output
------
Enter input filename: students.in
Students with birthday in the month Apr
Glee Apr 30 1999
Smile Apr 1 1997
Delight Apr 7 2002
===========