Answer to Question #238143 in C++ for Maria

Question #238143

Creat a class student consisting of data members register number, bame, gender, fees and age of the students and creat member function to read and display the student information


1
Expert's answer
2021-09-16T10:33:35-0400
#include <iostream>
#include <string>

class Student {
private:
    std::string registerNumber;
    std::string name;
    std::string gender;
    int fees = 0;
    int age = 0;
public:
    void read();
    void display();
};

void Student::read() {
    std::cout << "Enter information about student" << std::endl;
    std::cout << "Register number: ";
    std::cin >> registerNumber;
    std::cout << "Name: ";
    std::cin >> name;
    std::cout << "Gender: ";
    std::cin >> gender;
    std::cout << "Fees: ";
    std::cin >> fees;
    std::cout << "Age: ";
    std::cin >> age;
}

void Student::display() {
    std::cout << "Student information" << std::endl;
    std::cout << "Register number: " << registerNumber << std::endl;
    std::cout << "Name: " << name << std::endl;
    std::cout << "Gender: " << gender << std::endl;
    std::cout << "Fees: " << fees << std::endl;
    std::cout << "Age: " << age << std::endl;
}

int main() {
    Student student;
    student.read();
    std::cout << std::endl;
    student.display();
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS