هذا السؤال :
Assignment # 3.A: Struct (Records)
PART(A)
1. Write the definition of a structure type named
nameType, which includes the following components: firstName, middleName and lastName.
2. Write the definition of a structure type named
dateType, which include the following components: day, month, and year;
3. Write the definition of a structure type named
personType, which include the following components: ID of type long, name of type
nameType, and DateOfBirth of type
dateType.
4. Write a function named
getData that take as parameter:
list: an array of type
personType, and
size: number of items in the Employees array. The function should prompt the user to enter the ID, name, and DateOfBirth of all Employees.
5. Write a function named
printName that take as parameter:
emp of type
personType. The function should output the name (first name and last name) of
emp.
6. Write a function named
bornOnJuly that take as parameter:
a.
Employees: an array of type
personType.
b.
size: number of items in the Employees array.
The function should print the names (first name and last name) of all Employees born on July. Use
printName function to print the names.
PART(B)
Write a main program to do the following:
1. Declare an array named
list of 5 elements of type
personType.
2. Use the function
getData to enter the data of
list.
3. Call the function
bornOnJuly to print the names of employees born on July.
Assignment # 3.A: Struct (Records)
PART(A)
1. Write the definition of a structure type named
nameType, which includes the following components: firstName, middleName and lastName.
2. Write the definition of a structure type named
dateType, which include the following components: day, month, and year;
3. Write the definition of a structure type named
personType, which include the following components: ID of type long, name of type
nameType, and DateOfBirth of type
dateType.
4. Write a function named
getData that take as parameter:
list: an array of type
personType, and
size: number of items in the Employees array. The function should prompt the user to enter the ID, name, and DateOfBirth of all Employees.
5. Write a function named
printName that take as parameter:
emp of type
personType. The function should output the name (first name and last name) of
emp.
6. Write a function named
bornOnJuly that take as parameter:
a.
Employees: an array of type
personType.
b.
size: number of items in the Employees array.
The function should print the names (first name and last name) of all Employees born on July. Use
printName function to print the names.
PART(B)
Write a main program to do the following:
1. Declare an array named
list of 5 elements of type
personType.
2. Use the function
getData to enter the data of
list.
3. Call the function
bornOnJuly to print the names of employees born on July.
وين الاخطاء ..
HTML:
#include <iostream>#include <string>using namespace std;
Struct nameType {string firstName;string middleName;string lastName;
};
Struct dateType{int day;int month;int year;
};
Struct personType{long ID ;nameType name;dateType DateOfBirth ;
};
void getData( personType list[] ,int size ) { for (int i=0 ; i<size; i++) { cout<<"Enter the ID & name :"<<endl; cin>>ID>>name; cout<<"Enter the Date Of Birth of all Employees(day,month,year):"<<endl; cin>>day>>month>>year; }}
void printName ( personType emp ){ cout<<"The first name and last name :"<<endl; cout<<firstName<<lastName<<endl;
}
void bornOnJuly ( personType Employees[] , int size ) for (int i=0 ; i<size; i++) { if (month==7) printName (emp); }
int main(){int list [5];int size=5;
getData (list , size);
bornOnJuly (Employees , size);
system("pause"); return 0; }
اتمنى رد سريع و أكون شاكر لكم