Suppose we want to keep the following information for each student in the department:
ID - long integer
Phone Number - 3 pieces (area code (integer), prefix (integer), and
suffix (integer))
Date of Birth - 3 pieces (month (integer), day (integer), and year
(integer) )
Overall GPA - float
First Letter of Last name - char
First Letter of First Name - char
We want to assign the following values to student1 and student2, respectively:
Student1:
ID - 444444444
Phone Number (3 pieces) - 828, 888, 8888
Date of Birth (3 pieces) - 11, 21, 1985
Overall GPA - 3.45
First Letter of Last Name: T
First Letter of First Name: R
Student2:
ID - 555555555
Phone Number (3 pieces) - 828, 777, 7777
Date of Birth (3 pieces) - 9, 2, 1965
Overall GPA - 3.05
First Letter of Last Name: S
First Letter of First Name: G
1) Assuming we don't know about structures and classes, how do you assign these values to student1? Write the program segment that declares the required variables, then assign the above values to student1:
2)Assuming we don't know about structures and classes, how do you assign the values to student1 and student2 in the same program? Write the program segment that declares the required variables, then assign the values to student1 and student2.
As you have noticed, assigning such values to many students without
packing all of this information into one variable is a very difficult task. To answer question 3 and 4, you can use classes or structures.
3) Rewrite the program segments for question 1) and 2), but this time use either a struct or a class (whatever you feel it is the appropriate one).
4) Write the program segment to determine which one of these students is younger.
Instructions to return your lab to the teacher: (5 points penalty if instructions are not followed appropriately)
Congratulations! You have completed another Lab of CS I !! :-)