Write a program that define
A- a struct Teacher with the following members:
1. string variable name
2. integer variable age
B- a struct Course with the following members
1. string variable name for the course name
2. integer variable id for the course id
3. an object T of Teacher struct
C- in the main declare an object C and an array of objects CArray of 10 elements of Course struct
D- By using cin, read the course name, course id, teacher name and teacher age and save them in C object
E- Save the object C in the array and read the next record and save it in the array and so on..
F- Pass the array to the function Print that will print the contents of the array
Example: ObjectOrientedDesigne 112 by Dr. Ali 40 years old
this is the question
when i write the cod i found a problem to under stand who i can read the course name, course id, teacher name and teacher age and save them in C object.
and how to Save the object C in the array and read the next record and save it in the array and so on..
this is my code but i cant finish it and the due date is today please help
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
|
#include<iostream>
#include<string>
using namespace std;
struct Teacher
{
string name;
int age;
};
struct Course
{
string name_course;
int id;
Teacher T;
};
int main()
{
Course c;
Course Array_c[10];
cout<<endl;
cout<<"Please enter the course name : ";
cin>>c.name_course;
cout<<"Please enter the course id : ";
cin>>c.id;
cout<<"Please enter the teacher name : ";
cin>>c.T.name;
cout<<"Please enter the teacher age : ";
cin>>c.T.age;
return 0;
}
|