Design a Student Management System

C++C++Beginner
Practice Now

Introduction

In this challenge, you are tasked with designing a robust and secure student management class in C++ to help schools efficiently manage student information in the digital age. The goal is to create a Student class with private data members for name, age, and GPA, and implement public setter methods to set and display student information.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL cpp(("C++")) -.-> cpp/OOPGroup(["OOP"]) cpp(("C++")) -.-> cpp/BasicsGroup(["Basics"]) cpp/BasicsGroup -.-> cpp/data_types("Data Types") cpp/OOPGroup -.-> cpp/classes_objects("Classes/Objects") cpp/OOPGroup -.-> cpp/encapsulation("Encapsulation") subgraph Lab Skills cpp/data_types -.-> lab-446288{{"Design a Student Management System"}} cpp/classes_objects -.-> lab-446288{{"Design a Student Management System"}} cpp/encapsulation -.-> lab-446288{{"Design a Student Management System"}} end

Design a Student Management System

In the digital age, schools need efficient ways to manage student information. Your task is to create a robust and secure student management class in C++.

Tasks

  • Create a Student class with private data members for name, age, and gpa
  • Implement public setter methods to set student information
  • Create a public method to display student information

Requirements

  • Create a Student class with private data members name (string), age (int), and gpa (double).
  • Implement a setName method that accepts a string parameter and validates the name is not empty.
  • Implement a setAge method that accepts an integer parameter and validates age is between 0-120.
  • Implement a setGPA method that accepts a double parameter and validates GPA is between 0.0-4.0.
  • Create a displayInfo method that prints student information in this format:
    Student Name: <name>
    Student Age: <age>
    Student GPA: <gpa>
  • Save the implementation in ~/project/student.cpp file.
  • Include the required headers <iostream> and <string>.

Examples

Run the program to test your implementation:

g++ student.cpp -o student
./student

Example output of the program:

Student Name: Alice Johnson
Student Age: 20
Student GPA: 3.75

Hints

  • Use private access specifier for data members
  • Create setter methods with appropriate parameter validation
  • Use std::string for name
  • Implement input validation for age and GPA ranges
โœจ Check Solution and Practice

Summary

In summary, this challenge requires you to design a student management class in C++ that can efficiently store and display student information, including name, age, and GPA. You will need to implement private data members and public setter methods to meet the specified requirements, such as using std::string for name, int for age, and double for GPA. The final implementation should be saved in the ~/project/student.cpp file.