Coding language is C++ (4) Based on Problem P6.15. • Design a class Student. A s
ID: 3723559 • Letter: C
Question
Coding language is C++
(4) Based on Problem P6.15. • Design a class Student. A student has a name and a birthday. Make a vector vector friends; • Write a program in which the user is asked to enter a set of names and birthdays, thus populating the friends vector. See input-output for details. • After the list of students’ names and birthdays is read-in, implement a loop in which the user is asked to enter a month followed by a display of all students whose birthday falls into this month. • Comment 1. Note that the birthday entered must be in the format mm/dd/yyyy. • Comment 2. Note when the user is prompted to enter a month it must be a string, not an integer.
9:25 PM a ccle.ucla.edu ll T-Mobile 4) Baand on Problem P6.15 * Design dam Student. A student has name and a birthday Male vector vector«student» friends, Write a progrm in which the user is aoked to ester a set of aes and birthdays, th populating the friends veetor. See input-ostput Sor details HOMEWORK 4-DEADLINE MARCH 5, 11:50 PM After the list of students' names and ethlays is rewl-n implemest a loop in which the Comment 1. Note that the birthday entered mast be in the format /dd/yyyy Comaent 2 Note wben the er is peompted to enter a mosth it mt atring, an integer Submit the oltin as hew.S.4.epp tudento whe ere bere in priExplanation / Answer
#include<iostream>
#include<string>
#include<vector>
#include <sstream>
using namespace std;
int main(){
vector<string> friends,birthday;
string name,bday;
bool a=true;
cout << "Please enter names and birthday of friends (enter 0 to end) ";
do {
cin >> name;
friends.push_back (name);
cin >> bday;
birthday.push_back (bday);
if(name=="0" || bday=="0"){
a=false;
}
} while (a);
friends.pop_back();
birthday.pop_back();
for(int i=0;i<friends.size();i++){
cout<<friends[i]<<" "<<birthday[i]<<endl;
}
string month;
bool b=true;
do{
cout<<"Enter month : (enter 0 to end) ";
cin>>month;
for(int i=0;i<friends.size();i++){
if(birthday[i].substr(0,2) == month){
cout<<friends[i]<<endl;
}
}
if(month!="0"){
b=false;
}
}while(b);
return 0;
}