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

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...
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...
Classes and Objects Write a program that will create two classes; Services and Supplies. Class Services...
Classes and Objects Write a program that will create two classes; Services and Supplies. Class Services should have two private attributes numberOfHours and ratePerHour of type float. Class Supplies should also have two private attributes numberOfItems and pricePerItem of type float. For each class, provide its getter and setter functions, and a constructor that will take the two of its private attributes. Create method calculateSales() for each class that will calculate the cost accrued. For example, the cost accrued for...
C++ Assignment 1: Make two classes practice For each of the two classes you will create...
C++ Assignment 1: Make two classes practice For each of the two classes you will create for this assignment, create an *.h and *.cpp file that contains the class definition and the member functions. You will also have a main file 'main.cpp' that obviously contains the main() function, and will instantiate the objects and test them. Class #1 Ideas for class one are WebSite, Shoes, Beer, Book, Song, Movie, TVShow, Computer, Bike, VideoGame, Car, etc Take your chosen class from...
Create two child classes, UnderGraduateStudent and GraduateStudent that will extend from the Student class. Override the...
Create two child classes, UnderGraduateStudent and GraduateStudent that will extend from the Student class. Override the char getLetterGrade() method in each of the child classes. Use Student.java class defined below: (complete and compile) class Student {    private int id;    private int midtermExam;    private int finalExam;    public double calcAvg() {       double avg;       avg = (midtermExam + finalExam) / 2.0;       return avg;    }    public char getLetterGrade() {       char letterGrade = ‘ ‘;...
JAVA A simple Class in a file called Account.java is given below. Create two Derived Classes...
JAVA A simple Class in a file called Account.java is given below. Create two Derived Classes Savings and Checking within their respective .java files. (modify display() as needed ) 1. Add New private String name (customer name) for both, add a New int taxID for Savings only. 2. Add equals() METHOD TO CHECK any 2 accounts Demonstrate with AccountDemo.java in which you do the following: 3. Create 1 Savings Account and 3 Checking Accounts, where 2 checkings are the same....
The assignment is to write a class called data. A Date object is intented to represent...
The assignment is to write a class called data. A Date object is intented to represent a particuar date's month, day and year. It should be represented as an int. -- write a method called earlier_date. The method should return True or False, depending on whether or not one date is earlier than another. Keep in mind that a method is called using the "dot" syntax. Therefore, assuming that d1 and d2 are Date objects, a valid method called to...
C++ - When working on this assignment, focus on memorizing the syntax for writing classes. Write...
C++ - When working on this assignment, focus on memorizing the syntax for writing classes. Write a simple class named Circle, with three private variables: doubles named x, y and radius. The center of the circle is denoted by coordinates (x,y), and the radius of the circle is denoted by radius. It should have public member functions with the following signatures: void setRadius(double r) void setX(double value) void setY(double value) double getRadius() double getX() double getY() double getArea() bool containsPoint(double...
Programming II: C++ - Programming Assignment Vector Overloads Overview In this assignment, the student will write...
Programming II: C++ - Programming Assignment Vector Overloads Overview In this assignment, the student will write a C++ program that overloads the arithmetic operators for a pre-defined Vector object. When completing this assignment, the student should demonstrate mastery of the following concepts: · Object-oriented Paradigm · Operator Overloading - Internal · Operator Overloading - External · Mathematical Modeling Assignment In this assignment, the student will implement the overloaded operators on a pre-defined object that represents a Vector. Use the following...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT