class question

hello!
guys, can you help me find the error? because my output has wrong.thanks
#include<iostream>
#include<iomanip>
using namespace std;

class Increment
{
private:
char name[40],ratings;
float Sc_Point;

public:

char set_name()
{
cout<<"Enter Name :";
cin>>name;
cout<<endl;
}
float set_Sc_Point()
{
cout<<"Score Point :";
cin>>Sc_Point;
cout<<endl;
}
float set_rating()
{

if(Sc_Point>=3.00 && Sc_Point<=4.00)
ratings='A';
if(Sc_Point>=2.00 && Sc_Point<=2.99)
ratings='B';
if(Sc_Point>=0.00 && Sc_Point<=1.99)
ratings='F';
}
};

int main()
{
Increment M;
char name,ratings;
float Sc_Point;
cout<<"========================================================="<<endl;
cout<<"\tAGENT INFORMATION\t"<<endl;
cout<<"========================================================="<<endl;
M.set_name();
M.set_Sc_Point();
M.set_rating();

cout<<"========================================================="<<endl;
cout<<"\tINCREMENT SLIP\t"<<endl;
cout<<"========================================================="<<endl;
cout<<"Name :"<<name<<endl;;
cout<<"Point Awarded :"<<Sc_Point<<endl;
cout<<"Rating :"<<ratings<<endl;
}
What error? Why do you think there's an error? Why aren't you giving us the complete, specific information that would help us help you?

And please use code tags when posting code, to make it readable:

http://www.cplusplus.com/articles/z13hAqkS/
Last edited on
Your set_*() methods are declared to return a value, but they don't return anything.

The last 3 lines are printing the local variables name, Sc_Point and ratings that you declare at the beginning of main(). You want to print the members of M instead. So it should be
1
2
3
 cout << "Name :" << M.name << endl;;
    cout << "Point Awarded :" << M.Sc_Point << endl;
    cout << "Rating :" << M.ratings << endl;

The only problem with this is that you've declared those variables to be private, so make them public or add methods to get their value.
Topic archived. No new replies allowed.