The CGPA Calculator is a C++ program that allows users to manage student information and calculate CGPA (Cumulative Grade Point Average). This program interacts with a MySQL database to store and retrieve student details and grades. It provides options to add new student details, calculate the CGPA of a student, and print all students' CGPA.
- Add Student: Enter details for a new student, including ID, name, and grades for various subjects.
- Find CGPA: Calculate and display the CGPA of a student based on their grades.
- Print All Students' Data: Display all students' details along with their CGPA.
- MySQL database server
- MySQL Connector/C++ (for database connectivity)
- C++ compiler (e.g., g++)
- Install MySQL: Ensure that MySQL is installed and running on your system. Create a MySQL user and grant necessary privileges.
- Install MySQL Connector/C++: Download and install the MySQL Connector/C++ from the official MySQL website.
- Configure Database Credentials:
Create the
creds.hfile with your MySQL username and password in the following format:#include<string> namespace creds { std::string username = "username"; std::string password = "password"; };
- Compile the Program:
Use a C++ compiler to compile the program. For example, using
g++:g++ -o CGPACalculator CGPACalculator.cpp -lmysqlcppconn
- Run the Program:
Execute the compiled program:
./CGPACalculator
- Add Student:
- Select option 1 to enter new student details.
- Provide the student's ID, first name, last name, and grades for each subject.
- Find CGPA:
- Select option 2 to find the CGPA of a student.
- Enter the student ID to view their CGPA.
- Print All Students' Data:
- Select option 3 to display all students' details and CGPA.
- Exit:
- Select option 4 to exit the program.
CGPACalculator.cpp: Main C++ source file containing the program logic.CGPACalculator.h: Header file for theCGPACalculatorclass.creds.h: File containing database credentials.
- SQL errors are handled and printed to the console. Ensure that your MySQL server is running and the database credentials are correct.
This project is licensed under the MIT License. See the LICENSE file for details.