Question

C++ : Create a class called Student. The class includes four data items: studentId, studenName, courseNo...

C++

: Create a class called Student. The class includes four data items: studentId, studenName, courseNo and enrolmentstatus. Define a constructor to get the values of the data members and a member function named void display() to display the values of the data members. Write a class driver to test your class.

Homework Answers

Answer #1


#include <iostream>

using namespace std;
class Student {
private:
int studentId;

string studentName;
int courseNo;
string enrolmentstatus;
public:
  
Student(int studentId,string studentName,int courseNo,string enrolmentstatus) {
this->studentId=studentId;
this->studentName=studentName;
this->courseNo=courseNo;
this->enrolmentstatus=enrolmentstatus;
  
}
void display()
{
cout<<studentId<<" "<<studentName<<" "<<courseNo<<" "<<enrolmentstatus<<endl;
}   
};

int main()
{//performing a driver test by creating two object of class which check the status of student
Student s1=Student(1,"Amar",709,"verified");
Student s2=Student(2,"Namo",809,"NotVerifed");
s1.display();
s2.display();
  

return 0;
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
C++ Do not use constructors Create a class named Coord in C++ Class has 3 private...
C++ Do not use constructors Create a class named Coord in C++ Class has 3 private data items               int xCoord;               int yCoord;               int zCoord; write the setters and getters. They should be inline functions               void setXCoord(int)             void setYCoord(int)            void setZCoord(int)               int getXCoord()                     int getYCoord()                   int getZCoord() write a member function named void display() that displays the data items in the following format      blank line      xCoord is                          ????????      yCoord is                          ????????...
In C++ Employee Class Write a class named Employee (see definition below), create an array of...
In C++ Employee Class Write a class named Employee (see definition below), create an array of Employee objects, and process the array using three functions. In main create an array of 100 Employee objects using the default constructor. The program will repeatedly execute four menu items selected by the user, in main: 1) in a function, store in the array of Employee objects the user-entered data shown below (but program to allow an unknown number of objects to be stored,...
Create a class called time that has three data members hours, minutes, and seconds. The class...
Create a class called time that has three data members hours, minutes, and seconds. The class has the following member functions: - Overloaded Constructors - Display function to display it, in 11:59:59 format. - SetTime() - IsValid(): Check if the time is valid or not - AddTime(Time t1, Time t2): Add two time values passed as a parameter leaving the result in third time variable. - Increment(): Tells what will be time after a second - Decrement(): Tells what was...
Create and implement a class called clockType with the following data and methods Data: Hours, minutes,...
Create and implement a class called clockType with the following data and methods Data: Hours, minutes, seconds Methods: Set and get hours Set and get minutes Set and get seconds printTime(…) to display time in the form of hh:mm:ss default and overloading constructor
Has to be written in C#! Write a program that includes an Employee class that can...
Has to be written in C#! Write a program that includes an Employee class that can be used to calculate and print the take-home pay for a commissioned sales employee. Items to include as data members are employee number, first name, last name, and total sales. All employees receive 9% of the total sales of the month. Federal tax rate is 18%. Retirement contribution is 10%. Social Security tax rate is 6%. Use appropriate constants, design an object-oriented solution, and...
Write Python code to define a class called Student. The Student class should have the following...
Write Python code to define a class called Student. The Student class should have the following private fields: name – to store the name of a student attend – to store how many times a student attend the class grades – a list of all student’s grades The Student class should have the following methods: a constructor getter method for the name field attendClass method: that increments the attend field (should be called every time a student attends the class)....
In C++ PART 1: Write a constructor for a class data type named Test that has...
In C++ PART 1: Write a constructor for a class data type named Test that has the following two member variables: double arr*; int size; The constructor should take one argument for the size and then dynamically allocate an array of that size. PART 2: Write a destructor for the Test class.
In c++ create a class to maintain a GradeBook. The class should allow information on up...
In c++ create a class to maintain a GradeBook. The class should allow information on up to 3 students to be stored. The information for each student should be encapsulated in a Student class and should include the student's last name and up to 5 grades for the student. Note that less than 5 grades may sometimes be stored. Your GradeBook class should at least support operations to add a student record to the end of the book (i.e., the...
write a c++ program A class called car (as shown in the class diagram) contains: o...
write a c++ program A class called car (as shown in the class diagram) contains: o Four private variables: carId (int), carType (String), carSpeed (int) and numOfCars (int). numOfCars is a static counter that should be  Incremented whenever a new Car object is created.  Decremented whenever a Car object is destructed. o Two constructors (parametrized and copy constructor) and one destructor. o Getters and setters for the Car type, ID, and speed. And static getter function for numOfCars....
Create a class called Employee that contains three instance variables (First Name (String), Last Name (String),...
Create a class called Employee that contains three instance variables (First Name (String), Last Name (String), Monthly Salary (double)). Create a constructor that initializes these variables. Define set and get methods for each variable. If the monthly salary is not positive, do not set the salary. Create a separate test class called EmployeeTest that will use the Employee class. By running this class, create two employees (Employee object) and print the annual salary of each employee (object). Then set the...