Question

In: Computer Science

C++ HW Aim of the assignment is to write classes. Create a class called Student. This...

C++ HW

Aim of the assignment is to write classes. Create a class called Student. This class should contain information of a single student.

last name,

first name,

credits,

gpa,

date of birth,

matriculation date,

** you need accessor and mutator functions. You need a constructor that initializes a student by accepting all parameters. You need a default constructor that initializes everything to default values. write the entire program.

Solutions

Expert Solution

If you have any doubts, please give me comment...

#include<iostream>

using namespace std;

class Student{

    private:

        string lastName;

        string firstName;

        int credits;

        double gpa;

        string dateOfBirth;

        string matriculationDate;

    public:

        Student(){

            lastName = "";

            firstName = "";

            credits = 0;

            gpa = 0.0;

            dateOfBirth = "01/01/1901";

            matriculationDate = "01/01/2000";

        }

        Student(string lname, string fname, int _credits, double _gpa, string dob, string matricDate){

            lastName = lname;

            firstName = fname;

            credits = _credits;

            gpa = _gpa;

            dateOfBirth = dob;

            matriculationDate = matricDate;

        }

        void setLastName(const string &lname){

            lastName = lname;

        }

        void setFirstName(const string &fname){

            firstName = fname;

        }

        void setCredits(int _credits){

            credits = _credits;

        }

        void setGpa(double _gpa){

            gpa = _gpa;

        }

        void setDateOfBirth(string dob){

            dateOfBirth = dob;

        }

        void setMatriculationDate(string matricDate){

            matriculationDate = matricDate;

        }

        string getLastName(){

            return lastName;

        }

        string getFirstName() const{

            return firstName;

        }

        int getCredits() const{

            return credits;

        }

        double getGpa() const{

            return gpa;

        }

        string getDateOfBirth() const{

            return dateOfBirth;

        }

        string getMatriculationDate() const{

            return matriculationDate;

        }

        friend ostream &operator<<(ostream &out, const Student &student);

};

ostream &operator<<(ostream &out, const Student &student){

    out<<"Name: "<<student.firstName<<", "<<student.lastName<<endl;

    out<<"Credits: "<<student.credits<<endl;

    out<<"GPA: "<<student.gpa<<endl;

    out<<"Date of Birth: "<<student.dateOfBirth<<endl;

    out<<"Matriculation Date: "<<student.matriculationDate<<endl;

    return out;

}

int main(){

    Student student;

    cout<<"By student default argument constructor"<<endl;

    cout<<student<<endl;

    Student student2("NAGA", "ANU", 40, 3.5, "10-03-1993", "05-05-2009");

    cout<<"By initializing all parameters"<<endl;

    cout<<student2<<endl;

    return 0;

}


Related Solutions

Language C++ Student-Report Card Generator: create a class called student and class called course. student class...
Language C++ Student-Report Card Generator: create a class called student and class called course. student class this class should contain the following private data types: - name (string) - id number (string) - email (s) - phone number (string) - number of courses (int) - a dynamic array of course objects. the user will specify how many courses are there in the array. the following are public members of the student class: - default constructor (in this constructor, prompt the...
Write a C++ programs to: 1. Create a class called Student with four (4) private member...
Write a C++ programs to: 1. Create a class called Student with four (4) private member variables, name (string), quiz, midterm, final (all double type); 2. Include all necessary member functions for this class (at least 1 constructor, 1 get function, and 1 grading function – see #6); 3. Declare three (3) objects of Student type (individual or array); 4. Read from the keyboard three (3) sets of values of name, quiz, midterm, final and assign them to each object;...
Needed in C++ In this assignment, you are asked to create a class called Account, which...
Needed in C++ In this assignment, you are asked to create a class called Account, which models a bank account. The requirement of the account class is as follows (1) It contains two data members: accountNumber and balance, which maintains the current account name and balance, respectively. (1) It contains three functions: functions credit() and debit(), which adds or subtracts the given amount from the balance, respectively. The debit() function shall print ”amount withdrawn exceeds the current balance!” if the...
Create a class called Student which stores • the name of the student • the grade...
Create a class called Student which stores • the name of the student • the grade of the student • Write a main method that asks the user for the name of the input file and the name of the output file. Main should open the input file for reading . It should read in the first and last name of each student into the Student’s name field. It should read the grade into the grade field. • Calculate the...
In this assignment you are going to create a Student class to demonstrate a Student object....
In this assignment you are going to create a Student class to demonstrate a Student object. Then create a StudentTest class to place the main method in, which demonstrates the Student object. Student class should have the following instance variables: firstName, middleName, lastName (String) id (int) grade (int) Student class should have the following methods: Set and Get methods for each variable Constructor that sets all variables using Set methods that you defined. Design the application in main that you...
C++ Classes & Objects Create a class named Student that has three private member: string firstName...
C++ Classes & Objects Create a class named Student that has three private member: string firstName string lastName int studentID Write the required mutator and accessor methods/functions (get/set methods) to display or modify the objects. In the 'main' function do the following (1) Create a student object "student1". (2) Use set methods to assign StudentID: 6337130 firstName: Sandy lastName: Santos (3) Display the students detail using get functions in standard output using cout: Sandy Santos 6337130
In C# Create classes: Person, Student, Employee, Professor, Staff and Address ☐ Address class must have...
In C# Create classes: Person, Student, Employee, Professor, Staff and Address ☐ Address class must have suitable auto-implemented properties for Address 1, Address 2 and City. ☐ Person class must have suitable auto-implemented properties for Name, Residence (type Address) and email. ☐ Student and Employee must be subclasses of Person. ☐ Employee must be a super class for Professor and Staff. ☐ Employee class must have suitable auto-implemented properties for salary (between 2000 to 8000), and hire date. ☐ Professor...
IN C# Create classes: Person, Student, Employee, Professor, Staff and Address ☐ Address class must have...
IN C# Create classes: Person, Student, Employee, Professor, Staff and Address ☐ Address class must have suitable auto-implemented properties for Address 1, Address 2 and City. ☐ Person class must have suitable auto-implemented properties for Name, Residence (type Address) and email. ☐ Student and Employee must be subclasses of Person. ☐ Employee must be a super class for Professor and Staff. ☐ Employee class must have suitable auto-implemented properties for salary (between 2000 to 8000), and hire date. ☐ Professor...
C++ Assignment 1) Write a C++ program specified below: a) Include a class called Movie. Include...
C++ Assignment 1) Write a C++ program specified below: a) Include a class called Movie. Include the following attributes with appropriate types: i. Title ii. Director iii. Release Year iv. Rating (“G”, “PG”, “PG-13”, etc) - Write code that instantiates a movie object using value semantics as text: - Write code that instantiates a movie object using reference semantics: - Write the print_movie method code: - Write Constructor code: - Write Entire Movie class declaration
HW 8-1a   1.)   Referring to the UML class diagram, create a program that utilizes the Student...
HW 8-1a   1.)   Referring to the UML class diagram, create a program that utilizes the Student class. - id : Integer - units : Integer - name : String + Student ( ) : + Student (id : Int, name : String, units : Int) : + ~Student( ) : + setID(id : Integer) : void + setName(name: String) : void + setUnits(units : Integer ) : void + displayRecord() : void 2.)   Include 3 files: -   Source.cpp -   Student.h...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT