يصير أحد يكتشف لنا الخطأ
مو راضي يشتغل البرنامج

. .
[FONT="]ITCS102 Assignment#2 [/FONT]
[FONT="]Structures I[/FONT]
[FONT="] [/FONT]
[FONT="]1. Define a structure called
Student with data members such as:[/FONT]
[FONT="]string name; int cpr; int age; float gpa;[/FONT]
[FONT="] [/FONT]
[FONT="]2. Write a function called [/FONT][FONT="]readStudent[/FONT][FONT="] ( ….) t[/FONT][FONT="]hat receives a parameter by reference(address) called aStud of type Student. Using cout/cin, prompt the user to read all the data members of aStud.[/FONT]
[FONT="] [/FONT]
[FONT="]3. Write a function called [/FONT][FONT="]displayStudent[/FONT][FONT="] [/FONT][FONT="]( ….) t[/FONT][FONT="]hat receives a parameter by copy called aStud of type Student. UsThe function display tall the aStud information in a formatted way.[/FONT]
[FONT="] [/FONT]
[FONT="]4. Write a function called [/FONT]
[FONT="]bestStudent[/FONT][FONT="](…)[/FONT][FONT="] [/FONT][FONT="]that receives two parameters by copy called aStud1 and aStud2 both of type
Student. The function output the name of the one who got the highest gpa.[/FONT]
[FONT="] [/FONT]
[FONT="] [/FONT]
[FONT="]5. write a main function where you:[/FONT]
[FONT="] [/FONT]
[FONT="]5.1 [/FONT][FONT="]declare two variables called stud1 and stud2 both of type
Student. [/FONT]
[FONT="]5.2 [/FONT][FONT="]Call the function readStudent to read data in stud1.[/FONT]
[FONT="]Call the function readStudent to read data in stud2.[/FONT]
[FONT="]5.3 [/FONT][FONT="]Call the function bestStudent to see which of stud1 and stud2 got a better gpa.[/FONT]
[FONT="]5.4 [/FONT][FONT="]Call the function displayStudent to output stud1 info.[/FONT]
[FONT="]5.5 [/FONT][FONT="]Call the function displayStudent to output stud2 info.[/FONT]
[FONT="] [/FONT]
. ...............................
# include<iostream>
using namespace std;
struct Student {
string name;
int cpr;
int age;
float gpa;
};
void readStudent ( Student& aStud ){
cout << " read all the data members of aStud" << endl;
cin >> aStud.name << endl;
cin >> aStud.cpr << endl;
cin >> aStud.age << endl;
cin >> aStud.gpa << endl;
}
void displayStudent ( Student aStud){
cout << aStud.name << endl;
cout << aStud.cpr << endl;
cout << aStud.age << endl;
cout << aStud.gpa << endl;
}
void bestStudent ( Student aStud1, Student aStud2){
if ( aStud1.gpa > aStud2.gpa)
cout << aStud1.name;
else
cout << aStud2.name;
}
int main (){
Student stud1, stud2;
readStudent ( stud1);
readStudent (stud2);
bestStudent ( stud1, stud2);
displayStudent (stud1);
displayStudent( stud2);
return 0;
}