C++ code:
student.h:
#ifndef STUDENT_H
#define STUDENT_H
#include <string>
using namespace std;
class Student
{
private:
int ID;
string first_name;
string last_name;
string date_of_birth;
int area_code;
string telephone_number;
string address;
public:
Student();
void setStudent(int ID, string first_name, string last_name, string
date_of_birth, string address, int code, string phn);
int getID();
void setID(int id);
string getFirstName();
void setFirstName(string fn);
string getLastName();
void setLastName(string sn);
string getDOB();
void setDOB(string dob);
string getFullName();
string getAddress();
void setAddress(string addr);
string getTelephoneNumber();
void setTelephoneNumber(int code, string ph);
bool sameLastName(Student s2);
bool sameAddress(Student s1);
};
#endif
student.cpp:
#include "student.h"
#include <iostream>
#include <string>
using namespace std;
Student :: Student()
{
ID = 0;
first_name = "";
last_name = "";
date_of_birth = "";
address = "";
}
void Student :: setStudent(int ID, string first_name, string
last_name, string date_of_birth, string address, int code, string
phn)
{
this -> ID = ID;
this -> first_name = first_name;
this -> last_name = last_name;
this -> date_of_birth = date_of_birth;
this -> address = address;
this -> area_code = code;
this -> telephone_number = phn;
}
int Student :: getID()
{
return ID;
}
void Student :: setID(int ID)
{
this -> ID = ID;
}
string Student :: getFirstName()
{
return first_name;
}
void Student :: setFirstName(string name)
{
this -> first_name = name;
}
void Student :: setLastName(string name)
{
this -> last_name = name;
}
string Student :: getLastName()
{
return last_name;
}
void Student :: setAddress(string addr)
{
this -> address = addr;
}
string Student :: getAddress()
{
return address;
}
void Student :: setDOB(string dob)
{
this -> date_of_birth = dob;
}
string Student :: getDOB()
{
return date_of_birth;
}
string Student :: getFullName()
{
return first_name+last_name;
}
string Student :: getTelephoneNumber()
{
string tele = "" + area_code;
tele += "(" + telephone_number + ")";
return tele;
}
void Student :: setTelephoneNumber(int code, string phn)
{
this -> area_code = code;
this -> telephone_number = phn;
}
bool Student :: sameLastName(Student s2)
{
if(s2.last_name.compare(this->last_name) != 0) {
return false;
}
return true;
}
bool Student :: sameAddress(Student s2)
{
if(s2.address.compare(this->address) !=0 ) {
return false;
}
return true;
}
main.cpp:
#include <stdio.h>
#include <iostream>
#include "student.h"
#include <string>
using namespace std;
int main()
{
Student s1;
//s1.setStudent(1, "Ram", "Mohan", "06/10/1990", "Dallas", 469,
"613967");
Student s2;
//s1.setStudent(1, "John", "Lands", "22/03/1991", "San Antonio",
210, "723490");
string fn1,fn2,sn1,sn2,addr1,addr2,tlph1,tlph2,dob1,dob2;
int id1, id2, c1,c2;
cout << "Enter Student 1 details:\n";
cout << "Enter Students first name:\n";
cin >> fn1;
cout << "Enter Students second name:\n";
cin >> sn1;
cout << "Enter Students id:\n";
cin >> id1;
cout << "Enter Students address: \n";
cin >> addr1;
cout << "Enter Students DOB: \n";
cin >> dob1;
cout << "Enter Students area code: \n";
cin >> c1;
cout << "Enter Students telephone number:\n";
cin >> tlph1;
s1.setStudent(id1, fn1, sn1, dob1, addr1, c1, tlph1);
cout << "Enter Student 2 details:\n";
cout << "Enter Students first name:\n";
cin >> fn2;
cout << "Enter Students second name:\n";
cin >> sn2;
cout << "Enter Students id:\n";
cin >> id2;
cout << "Enter Students address: \n";
cin >> addr2;
cout << "Enter Students DOB: \n";
cin >> dob2;
cout << "Enter Students area code: \n";
cin >> c2;
cout << "Enter Students telephone number:\n";
cin >> tlph2;
s2.setStudent(id2, fn2, sn2, dob2, addr2, c2, tlph2);
bool slast_name = s1.sameLastName(s2);
if(slast_name) {
cout << "Both students have same last name."
<<endl;
} else {
cout << "The students do not have the same last name."
<< endl;
}
bool saddress = s1.sameAddress(s2);
if(saddress) {
cout << "Both the Students are roommates." <<
endl;
} else {
cout << "The Students are not roommates." <<
endl;
}
return 0;
}
Sample Output:
Enter Student 1 details:
Enter Students first name:
Ram
Enter Students second name:
Mohan
Enter Students id:
1
Enter Students address:
Dallas
Enter Students DOB:
06/05/1992
Enter Students area code:
469
Enter Students telephone number:
617890
Enter Student 2 details:
Enter Students first name:
Laxman
Enter Students second name:
Mohan
Enter Students id:
2
Enter Students address:
Dallas
Enter Students DOB:
16/12/1991
Enter Students area code:
469
Enter Students telephone number:
789324
Both students have same last name.
Both the Students are roommates.
Use C++ to create a class called Student, which represents the students of a university. A...
*** C++ *** Create a class called Student that contains a first name ( string) and an student id number (type long). 1. Include a member function called get_data( ) to get data from the user for insertion into the object, 2. Also include a function called display_data( ) that displays the student data. Then write a complete program that uses the class to do some computation. Your main function, main( ), should create a Dynamic Array of...
Complete Course.cpp by implementing the PrintRoster() function, which outputs a list of all students enrolled in a course and also the total number of students in the course.Given files: main.cpp - contains the main function for testing the program.Course.cpp - represents a course, which contains a vector of Student objects as a course roster. (Type your code in here)Course.h - header file for the Course class.Student.cpp - represents a classroom student, which has three data members: first name, last name, and...
about this question 2, I don't know how to do it in C++, can anyone help me out??? C 38s. A &X C Solved Get Hon (246) Th (242) A X PowerPo X X endrc Microso odle.concordia.ca/moodle/pluginfile.php/3796501/mod resource/content/1/A4 % 20- %20F2019 pdf COEN 243-Fall 2019 2. (25 marks) Define a class called "House", that represents the information of a house. A House is defined with these attributes: age (int), type (string) (Detached, Semi-Attached, Attached), rooms (int) and cost (double). Functions...
Create a java class for an object called Student which contains the following private attributes: a given name (String), a surname (family name) (String), a student ID number (an 8 digit number, String or int) which does not begin with 0. There should be a constructor that accepts two name parameters (given and family names) and an overloaded constructor accepting two name parameters and a student number. The constructor taking two parameters should assign a random number of 8 digits....
Write a C++ program that includes the following: Define the class Student in the header file Student.h. #ifndef STUDENT_H #define STUDENT_H #include <string> #include <iostream> using namespace std; class Student { public: // Default constructor Student() { } // Creates a student with the specified id and name. Student(int id, const string& name) { } // Returns the student name. string get_name() const { } // Returns the student id. int get_id () const { } // Sets the student...
Files given in this assignment (right-click on the file to download) Assignment7.cpp (need to complete) Student.h (Given. Just use it, don't change it!) Student.cpp (Partially filled, need to complete) 1. Assignment description In this assignment, you will write a simple class roster management system for ASU CSE100. Step #1: First, you will need to finish the design of class Student. See the following UML diagram for Student class, the relevant header file (class declaration) is given to you as Student.h,...
Create a class hierarchy to be used in a university setting. The classes are as follows: The base class is Person. The class should have 3 data members: personID (integer), firstName(string), and lastName(string). The class should also have a static data member called nextID which is used to assign an ID number to each object created (personID). All data members must be private. Create the following member functions: o Accessor functions to allow access to first name and last name...
could you solve this in C++ please 2. (25 marks) Define a class called "House", that represents the information of a house. A House is defined with these attributes: age (int), type (string) (Detached, Semi-Attached, Attached), rooms (int) and cost (double). Functions of the House class must perform the following operations: • Return the house age • Modify the house age • Return the house type • Return the number of rooms • A function called estimate Price() that returns...
I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student { private String name; private double gpa; private int idNumber; public Student() { this.name = ""; this.gpa = 0; this.idNumber = 0; } public Student(String name, double gpa, int idNumber) { this.name = name; this.gpa = gpa; this.idNumber = idNumber; } public Student(Student s)...
C++ Design: Create a UML Class diagram that reflects the software design of your entire program Q3. Create a class called Passenger that represents passengers of an airline company. A passenger is defined by the following information: - Passenger ID (int) - Name (string) - Address (string) - Tel (string) - Date of birth (of type Date from Q2) Provide the following functions: - A constructor that initializes the data members and provides default arguments. - Accessor methods that return...