Hi Guys,

I have an assignment to do a gpa calculator using class construction and an array of grades.

The assignment is to have a class called Student and have a user enter an ID and then enter however many grades they want and then have the program calculate the gpa depending on whatever they inputted. Here is what i got so far,

If you can help soon it would be great. Thanks,

include <iostream>
using namespace std;

class Student
{	private:
	int ID;
	float grades [5] = {4, 3, 2, 1, 0};
	Student(int = 0,float = 0);
	int nofgrades;
	float averagegpa;
	void getData();
	void showData();

float Student::averagegpa()
8 Years
Discussion Span
Last Post by n03ly

then enter however many grades they want

float grades [5] = {4, 3, 2, 1, 0};

Perhaps you can prompt the user how many students and how many grades each student will they input so you know how much to allocate your arrays.

float Student::averagegpa()

you know how to calculate avg right?
use a for loop go through each grade and sum it up and divide the number by the number of grades.


This is roughly how you would get the input, its not very hard but you need to have an understanding of loops and classes.

void Student::void getData(){
1)Use cout to print statement asking to enter the student id and save the input into your variable.
2)Use a loop and ask the user to enter the students results and keep saving until they enter eof or other terminating characters.

This should help you get started with the getData function.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.