I need help with the following question:
Design a structure Student containing the following members:
1) First Name;
2) Last name;
3) Date of birth (it should be in turn a structure containing three members Year, Month, Day); 4) Phone number;
5) Major field of study.
1. Write a function print_student_info that takes in a Student struct and print all its information.
2. Write another function search_students_by_lastname that take in an array of Student struct and string lastname as arguments and print the information of all students that match the given lastname. Use the print_student_info function in (1). If no structure matches, print a message “0 Matches found for the given lastname“.
3. Write another function search_students_by_yob that search for a student born in a particular year. It should take in an array of Student struct and an int yob as arguments and then search for all students with a birth year that matches it. Use print_student_info function to print the information of the matched structures. If no structure matches, print a message “0 Matches found for the given year of birth“
4. Write a main function to test the developed aforementioned functions. You should create an array of struct Student and fill it in with six students of arbitrary appropriate values. Then demonstrate the usage of search_students_by_lastname and search_students_by_yob functions.
This is what I have so far:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
#include <iostream>
#include <string>
using namespace std;
struct Student //creates structure student
{
char firstname; //listing variables inside structure
char lastname;
struct dob
{
int year;
int month;
int day;
};
dob a;
double number;
char major;
};
void print_student_info(Student s) //function that calls to structure Student
{
cout << "First Name: " << s.firstname << endl; //Prints student info
cout << "Last Name: " << s.lastname << endl;
cout << "Date of Birth(MMDDYYYY): " << s.a.month << s.a.day << s.a.year << endl;
cout << "Phone Number: " << s.number << endl;
cout << "Major Field of Study: " << s.major << endl;
}
void search_students_by_lastname(Student s)
{
struct Student lname[6];
int i;
for(i=0; i < 6; i++)
{
}
}
void search_students_by_yob(Student s)
{
}
int main()
{
}
|