#include<iostream>
#include<string>
using namespace std;
class student
{
public:
void input(string name, long id, int grade1, int grade2, int grade3);
void GPA(float) const;
void Display() const;
private:
string name;
int id;
int grade1;
int grade2;
int grade3;
};
int main()
{
string name;
int id;
int grade1,grade2,grade3;
float gradepoint;
student input(name, id, grade1,grade2,grade3);
student GPA();
student Display();
return 0;
}
void student::input(string name, int id, int grade1, int grade2, int grade3)
{
cout<<"enter student id number"<<endl;
cin>>id;
cout<<"enter student name"<<endl;
cin>>name;
cout<<"enter three grades"<<endl;
cin>>grade1;
cin>>grade2;
cin>>grade3;
}
void student:: GPA(float) const
{
float gradepoint;
int grade1, grade2, grade3;
gradepoint = (grade1 + grade2 + grade3) / 3;
}
void student:: Display() const
{
float gradepoint;
cout<<" Student Gradepoint average is: "<< gradepoint<<endl;
}
dachy12
0
Newbie Poster
Recommended Answers
Jump to PostIt's customary that one provides some accompanying information.
Jump to PostThere's no need to have a function
input()
like this:void student::input(string name, int id, int grade1, int grade2, int grade3) { cout<<"enter student id number"<<endl; cin>>id; cout<<"enter student name"<<endl; cin>>name; cout<<"enter three grades"<<endl; cin>>grade1; cin>>grade2; cin>>grade3; }
when you have your private members like …
All 6 Replies
Suzie999
245
Coding Hobbyist
mrnutty
761
Senior Poster
dachy12
0
Newbie Poster
VernonDozier
2,218
Posting Expert
Featured Poster
Lucaci Andrew
140
Za s|n
dachy12
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.