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

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...
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
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
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...
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...
***Given a class called Student and a class called Course that contains an ArrayList of Student....
***Given a class called Student and a class called Course that contains an ArrayList of Student. Write a method called dropStudent() as described below. Refer to Student.java below to learn what methods are available.*** Course.java import java.util.*; import java.io.*; /****************************************************** * A list of students in a course *****************************************************/ public class Course{ /** collection of Students */ private ArrayList<Student> roster; /***************************************************** Constructor for objects of class Course *****************************************************/ public Course(){ roster = new ArrayList<Student>(); } /***************************************************** Remove student with the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT