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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
#include <string>
#include <iostream>
using namespace std;
struct Student
{
string name;
string address;
string city;
string state;
string zip;
string gender;
string id;
double gpa;
};
Student getStudent();
Student getStudenta();
Student getStudentb();
void showStudent( Student& );
int main()
{
Student foo;
Student a;
Student b;
foo = getStudent ();
showStudent( foo );
a = getStudenta ();
showStudent ( a );
b = getStudentb ();
showStudent ( b );
}
Student getStudent()
{
Student s;
cout << "Enter for Student 1" << endl;
cout << " Name: ";
getline( cin, s.name );
cout << " Address: ";
getline( cin, s.address );
cout << " City: ";
getline( cin, s.city );
cout << " State: ";
getline( cin, s.state );
cout << " Zip: ";
getline( cin, s.zip );
cout << " Gender: ";
getline( cin, s.gender );
cout << " ID: ";
getline( cin, s.id );
cout << " GPA: ";
cin >> s.gpa;
cin.ignore( 1000, 10 );
return s;
}
Student getStudenta()
{
Student a;
cout << "Enter for Student 2" << endl;
cout << " Name: ";
getline( cin, a.name );
cout << " Address: ";
getline( cin, a.address );
cout << " City: ";
getline( cin, a.city );
cout << " State: ";
getline( cin, a.state );
cout << " Zip: ";
getline( cin, a.zip );
cout << " Gender: ";
getline( cin, a.gender );
cout << " ID: ";
getline( cin, a.id );
cout << " GPA: ";
cin >> a.gpa;
cin.ignore( 1000, 10 );
return a;
}
Student getStudentb()
{
Student b;
cout << "Enter for Student 3" << endl;
cout << " Name: ";
getline( cin, b.name );
cout << " Address: ";
getline( cin, b.address );
cout << " City: ";
getline( cin, b.city );
cout << " State: ";
getline( cin, b.state );
cout << " Zip: ";
getline( cin, b.zip );
cout << " Gender: ";
getline( cin, b.gender );
cout << " ID: ";
getline( cin, b.id );
cout << " GPA: ";
cin >> b.gpa;
cin.ignore( 1000, 10 );
return b;
}
void showStudent( Student& t)
{
cout << "Name: " << t.name << endl;
cout << "Address: " << t.address << endl;
cout << "City: " << t.city << endl;
cout << "State: " << t.state << endl;
cout << "Zip: " << t.zip << endl;
cout << "Gender: " << t.gender << endl;
cout << "ID: " << t.id << endl;
cout << "GPA: " << t.gpa << endl;
}
|