954,504 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

GPA calculator c++

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};
public:
Student(int = 0,float = 0);
int nofgrades;
float averagegpa;
void getData();
void showData();
}

{
float Student::averagegpa()
{

n03ly
Newbie Poster
2 posts since Oct 2008
Reputation Points: 10
Solved Threads: 0
 
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.

ff4930
Junior Poster in Training
58 posts since Oct 2007
Reputation Points: 34
Solved Threads: 3
 

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.

kenji
Junior Poster
145 posts since May 2008
Reputation Points: 11
Solved Threads: 11
 

thanks... ill work on it

n03ly
Newbie Poster
2 posts since Oct 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You