OVERDUE UPDATE:
Realized that I needed to declare my variables and set to each part of my calculation along with your correction Ketsuekiame. Thank you.
OVERDUE UPDATE:
Realized that I needed to declare my variables and set to each part of my calculation along with your correction Ketsuekiame. Thank you.
I am trying to do here is have my for loop go through the array for a single student and calculate GPA: (grade * credithour) + (grade * credithour) / (divide) credithour+credithour = gpa
For example, suppose a student had these grades:
A in 3 hour course
B in 3 hour course
A in 2 hour course
The GPA for this student would be:
((A * 3) + (B * 3) + (A * 2) )/ (3 + 3 + 2) =
((4 * 3) + (3 * 3) + (4 * 2) )/ (3 + 3 + 2) =
(12 + 9 + 8)/ (3 + 3 + 2) = 29/8 = 3.625 GPA
Hope this makes more sense.
sorry about that... here is the code for my .h files
student.h
#ifndef STUDENT_H
#define STUDENT_H
#include <iostream>
#include <string>
using namespace std;
class Student{
private:
string firstName;
string lastName;
string aNumber;
double GPA;
public:
Student ();
Student (string f, string l, string idNo, double gPoint);
string getfirstName () const;
void setfirstName (string f);
string getlastName () const;
void setlastName (string l);
string getaNumber () const;
void setaNumber (string idNo);
double getGPA ()const;
void setGPA (double gPoint);
};
#endif
and classinformation.h
class ClassInformation{
private:
int classNumber;
string className;
int creditHrs;
char letterGrade;
int pointGrade;
public:
ClassInformation ();
ClassInformation(int cNumber,string cName,int h, char g,int pg);
int getclassNumber() const;
void setclassNumber(int cNumber);
string getclassName() const;
void setclassName(string cName);
int getcreditHrs() const;
void setcreditHrs(int h);
char getletterGrade () const;
void setletterGrade (char g);
int getpointGrade () const;
void setpointGrade (int pg);
};
#endif
The error is " 7 IntelliSense: expression must be a modifiable lvalue c:\users\honeybunny\documents\visual studio 2010\projects\assignment5\assignment5\pass5.cpp 64
and Warning 1 warning C4552: '+' : operator has no effect; expected operator with side-effect c:\users\honeybunny\documents\visual studio 2010\projects\assignment5\assignment5\pass5.cpp 67"
I am trying to write a function that will compute GPA.
#include "Student.h"
#include "ClassInformation.h"
Student* setupStudent(){
string f,l,idNo;
double gPoint=0;
Student *studPtr1;
studPtr1 = new Student ();
cout<<"Enter first name ";
cin>>f;
studPtr1->setfirstName(f);
cout<<"Enter last name ";
cin>>l;
studPtr1->setlastName(l);
cout<<"Enter A number";
cin>>idNo;
studPtr1->setaNumber(idNo);
cout<<endl;
studPtr1->setGPA(gPoint);
return studPtr1;
}
ClassInformation* setupClassInformationArrary(int *length){
int *maxClasses;
ClassInformation *classInfo;
classInfo = new ClassInformation[*maxClasses];
return classInfo;
};
void readClassInformation(ClassInformation*singleGlass){
string cName;
int cNumber,h;
char g;
cout<<"Enter class name ";
cin>>cName;
singleGlass->setclassName(cName);//change these lines
cout<<"Enter class number";
cin>>cNumber;
singleGlass->setclassNumber(cNumber);
cout<<" Enter credit hours ";
cin>>h;
singleGlass->setcreditHrs(h);
cout<<"Enter student's letter grade";
cin>>g;
singleGlass->setletterGrade(g);
};
void computeGPA (Student *studPtr1,ClassInformation *singleGlass[],int numClasses){
int gpa=0;
for (int i=1;i<numClasses;i++){
"studPtr1.singleGlass[i].getletterGrade()"; *
"singleGlass[i].getcreditHrs()"/
gpa= gpa+ "singleGlass[i].getcreditHrs()";
}
// (grade * credithour) + (grade * credithour) / credithour+credithour = gpa
};
When I debug I have a warning of "+" operator has no effect, expected operator with side-effect.
Any help would be greatly appreciated. Thank you in advance.
Got it... needed to define within the function.
Student* setupStudent(){
string f,l,idNo;
double gPoint=0;
Student *studPtr1;
studPtr1 = new Student ();
cout<<"Enter first name ";
cin>>f;
studPtr1->setfirstName(f);
cout<<"Enter last name ";
cin>>l;
studPtr1->setlastName(l);
cout<<"Enter A number";
cin>>idNo;
studPtr1->setaNumber(idNo);
cout<<endl;
studPtr1->setGPA(gPoint);
return studPtr1;
}
Thank you for correcting my error...
Now with that now reading
Student* setupStudent(){
Student *studPtr1;
studPtr1 = new Student ();
cout<<"Enter first name ";
cin>>f;
studPtr1->setfirstName(f);
cout<<"Enter last name ";
cin>>l;
studPtr1->setlastName(l);
cout<<"Enter A number";
cin>>idNo;
studPtr1->setaNumber(idNo);
cout<<endl;
studPtr1->setGPA(gPoint);
{gPoint=0;}
return studPtr1;
do I still need to define my identifier? I figured that it should read in from the class Student..
Trying to define a function that dynamically creates a Student object and then prompts the user for the info and returns pointer to a Student object.
class Student{
private:
string firstName;
string lastName;
string aNumber;
double GPA;
public:
Student ();
Student (string f, string l, string idNo, double gPoint);
string getfirstName () const;
void setfirstName (string f);
string getlastName () const;
void setlastName (string l);
string getaNumber () const;
void setaNumber (string idNo);
double getGPA ()const;
void setGPA (double gPoint);
};
#endif
.cpp
void setupStudent(){
Student *studPtr1;
studPtr1 = new Student;
cout<<"Enter first name ";
cin>>f;
studPtr1->getfirstName();
cout<<"Enter last name ";
cin>>l;
studPtr1->getlastName();
cout<<"Enter A number";
cin>>idNo;
studPtr1->getaNumber();
cout<<endl;
studPtr1->setGPA(double gPoint);{
gPoint=0;}
return studPtr1;