There is a problem in my algorithm, where I am not being able to incorporate the clas

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Akhi999
    New Member
    • Feb 2014
    • 1

    There is a problem in my algorithm, where I am not being able to incorporate the clas

    Code:
    #include<iostream.h>
    #include<conio.h>
    #include<fstream.h>
    void enter();
    void result();
    class applicant
    {
    long ano;
    float agg;
    char name[30], grade;
    
    public:
    void grademe()
    {
    if (agg >= 80.0)
    {
    grade = 'A';
    }
    else if (agg < 80.0 && agg >= 65.0)
    {
    grade = 'B';
    }
    else if (agg < 65.0 && agg >= 50.0)
    {
    grade  = 'C';
    }
    else if (agg < 50.0 && agg >= 33.0)
    {
    grade = 'D';
    }
    else if (agg < 33.0)
    {
    grade = 'E';
    }
    }
    
    void enter()
    {
    cout<<"\nEnter the Applicant Number: "<<endl;
    cin>>ano;
    cout<<"\nEnter the Name: "<<endl;
    cin>>name;
    cout<<"\nEnter the Aggregate Marks: "<<endl;
    cin>>agg;
    grademe();
    }
    
    
    void result()
    {
    cout<<"\nApplicant Number: "<<ano;
    cout<<"\nName: "<<name;
    cout<<"\nAggregate Marks: "<<agg;
    cout<<"\nGrade: "<<grade;
    }
    };
    
    
    void main()
    {
    clrscr();
    applicant a;
    cout<<"_________________";
    cout<<"\nEnter the values: ";
    cout<<"\n``````````````````";
    a.enter();
    cout<<"\nTHE RESULT IS: ";
    a.result();
    
    
    applicant sub[5];
    fstream filin;
    filin.open("http://bytes.com/Applicant.txt", ios::in | ios::out);
    if (!filin)
    {
    cout<<"\nCannot open the file!!!";
    }
    else
    cout<<"\nData entered successfully.";
    
    }
    Last edited by Rabbit; Feb 2 '14, 06:57 PM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    I'll need more information. I ran your code and it works except for the aggregate calculation.

    Exactly what is your problem? Please explain more fully.

    Comment

    Working...