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 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
#include <iostream>
#include <string>
using namespace std;
struct date
{
int day;
int month;
int year;
};
struct address
{
string house_street;
string city;
string state;
string zip_code;
};
class StudentDetails
{
string name;
int id;
struct date dob;
struct address address;
int totalCreditEarned;
double GPA;
public:
StudentDetails(string n, int i = -1)
{
name = n;
id = i;
}
void setName(string n);
void setId(int i);
void setDate(int d, int m, int y);
void setAddress(string h, string c, string s, string z);
void setTotalCreditEarned(int t);
void setGPA(double g);
string getName();
int getId();
struct date getDate();
struct address getAddress();
int getTotalCreditEarned();
double getGPA();
};
void StudentDetails::setName(string n)
{
name = n;
}
void StudentDetails::setId(int i)
{
id = i;
}
void StudentDetails::setDate(int d, int m, int y)
{
dob.day = d;
dob.month = m;
dob.year = y;
}
void StudentDetails::setAddress(string h, string c, string s, string z)
{
address.house_street = h;
address.city = c;
address.state = s;
address.zip_code = z;
}
void StudentDetails::setTotalCreditEarned(int t)
{
totalCreditEarned = t;
}
void StudentDetails::setGPA(double g)
{
GPA = g;
}
string StudentDetails::getName()
{
return name;
}
int StudentDetails::getId()
{
return id;
}
struct date StudentDetails::getDate()
{
return dob;
}
struct address StudentDetails::getAddress()
{
return address;
}
int StudentDetails::getTotalCreditEarned()
{
return totalCreditEarned;
}
double StudentDetails::getGPA()
{
return GPA;
}
int main()
{
StudentDetails student("Dave");
string h, c, s, z;
int d, m, y;
int id;
int credit;
double gpa;
char temp;
cout << "Enter the Student ID: "<<endl;
cin >> id;
cout << "*****Enter the Birthday Details:*****"<<endl;
cout << "Day: ";
cin >> d;
cout << "Month: ";
cin >> m;
cout << "Year: ";
cin >> y;
getchar();
cout << "******Enter the Address Detials:*****"<<endl;
cout << "House # & Street: "<<endl;
getline(cin, h);
cout << "City: "<<endl;
getline(cin, c);
cout << "State: "<<endl;
getline(cin, s);
cout << "Zip Code: "<<endl;
getline(cin, z);
cout << "Enter the Total Credits Earned: "<<endl;
cin >> credit;
cout << "Enter the GPA: "<<endl;
cin >> gpa;
student.setId(id);
student.setDate(d, m, y);
student.setAddress(h, c, s, z);
student.setTotalCreditEarned(credit);
student.setGPA(gpa);
cout <<"**********VALIDATION**********:"<<endl<<endl;
if (student.getAddress().zip_code == "11235")
cout <<"Yes, The student " << student.getName() << "'s lives in the zip code is 11235"<<endl;
else
cout <<"No, The student " << student.getName() << "'s lives in the zip code is not 11235"<<endl;
if (student.getDate().month == 11)
cout << "Yes, The student " << student.getName() << "'s birthday is in November"<<endl;
else
cout << "No, The student " << student.getName() << "'s birthday is not in November"<<endl;
}
|