Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <iostream>
- #include <string>
- using namespace std;
- class Student{
- private:
- string name, grade, div, birthDate, bloodGroup, address, roll, license, phone;
- string email;
- static string college;
- public:
- Student(){
- name = "NAME SURNAME";
- grade = "CLASS";
- div = "DIVISION";
- birthDate = "01/01/2000";
- bloodGroup = "BLOOD GROUP";
- address = "ADDRESS";
- roll = "00";
- phone = "0000000000";
- license = "0LX000000";
- }
- Student(const Student &obj){
- name = obj.name;
- grade = obj.grade;
- div = obj.div;
- birthDate = obj.birthDate;
- bloodGroup = obj.bloodGroup;
- address = obj.address;
- roll = obj.roll;
- phone = obj.phone;
- license = obj.license;
- }
- void initData(){
- cout << "\n ----- ENTER STUDENT DETAILS -----" << endl;
- cout << "Enter Name: "; getline(cin, name);
- cout << "Enter Class: "; getline(cin, grade);
- cout << "Enter Division: "; getline(cin, div);
- cout << "Enter Date of Birth: "; getline(cin, birthDate);
- cout << "Enter Blood Group: "; getline(cin, bloodGroup);
- cout << "Enter Address: "; getline(cin, address);
- cout << "Enter Roll No.: "; getline(cin, roll);
- cout << "Enter Phone No.: "; getline(cin, phone);
- // Exception Handling for Phone Number (Checking if Phone Number exceeds 10 digits)
- cout << "Enter Email: "; getline(cin, email);
- // Vewy Basic Exception Handling for email (Checking for the '@' character)
- int flag = 0;
- try {
- for (int i = 0; i < email.size(); i++){
- if (email[i] == '@') {
- flag = 1;
- break;
- }
- }
- if (flag == 0) {
- throw(email);
- }
- } catch (string email1) {
- cout << "ERROR! Please enter a Valid Email!" << endl;
- cout << "Enter a Valid Email: ";
- getline(cin, email);
- }
- cout << "Enter Driving License No.: "; getline(cin, license);
- cout << endl;
- }
- void displayData(){
- cout << "\n STUDENT DETAILS FOR: " << name << endl;
- cout << "--------------------------" << endl;
- cout << "Name: " << name << endl;
- cout << "Class: " << grade << endl;
- cout << "Division: " << div << endl;
- cout << "Roll No.: " << roll << endl;
- cout << "Date of Birth: " << birthDate << endl;
- cout << "Blood Group: " << bloodGroup << endl;
- cout << "Address: " << address << endl;
- cout << "Phone No.: " << phone << endl;
- cout << "Email : " << email << endl;
- cout << "Driving License No.: " << license << endl;
- cout << "Institute: " << college << endl;
- cout << endl;
- }
- static void getCollege(){
- cout << college << endl;
- }
- };
- string Student::college = "International Institute of Information Technology";
- int main(){
- Student S1;
- S1.initData();
- S1.displayData();
- Student::getCollege();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment