8 Replies - 309 Views - Last Post: 06 February 2012 - 03:11 PM Rate Topic: -----

#1 StormRonin  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 62
  • Joined: 27-May 10

Problem with Code for a grading program

Posted 06 February 2012 - 02:13 PM

error C2628: 'studentre' followed by 'void' is illegal (did you forget a ';'?)
: error C2556: 'studentre studentre::getgrade(double,double,double,double)' : overloaded function differs only by return type from 'void studentre::getgrade(double,double,double,double)'
: see declaration of 'studentre::getgrade'
error C2371: 'studentre::getgrade' : redefinition; different basic types
see declaration of 'studentre::getgrade'
error C2511: 'void studentre::getaverage(double)' : overloaded member function not found in 'studentre'
: see declaration of 'studentre'


#include <iostream>
#include <cmath>
using namespace std;

class studentre
{
public:
	double quiz1,quiz2;
	double midterm;
    double final;
    double average;
    double numeric_score;
	void getgrade(double,double,double,double);
	void getaverage(double);
	void display();
}

void studentre::getgrade(double quiz1a, double quiz2a,double midterma,double finala)
{
	quiz1a=quiz1/10;
	quiz2a=quiz2/10;
	midterma=midterm/100;
	finala=final/100;
}
void studentre::getaverage(double average)
{
	average = ( (midterm / 100) * .25 ) + ( ( quiz1/10 ) * .125 ) + ( ( quiz2/10 ) * .125 ) + ( ( final/100 ) * .50);
}
void studentre::display()
{
	cout<< "Your quiz one is"<<quiz1<<endl;
	cout<< "Your second Quiz is"<<quiz2<<endl;
	cout<<" Your midterm is"<<midterm<<endl;
	cout<<" Your final is"<<final<<endl;
	cout<<" Your average is"<<average<<endl;
}
int main()
{
     cout<< "Enter first quiz mark: " << quiz1 <<endl;
     cin>>quiz1;
     cout<< "Enter second quiz mark: "<< quiz2<<endl;
     cin>>quiz2;
     cout<< "Enter midterm exam mark: "<<midterm<<endl;
     cin>>midterm;
     cout<< "Enter final exam mark: " << final<<endl;
     cin>>final;
     system ("pause");

    }


Is This A Good Question/Topic? 0
  • +

Replies To: Problem with Code for a grading program

#2 StormRonin  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 62
  • Joined: 27-May 10

Re: Problem with Code for a grading program

Posted 06 February 2012 - 02:18 PM

sorry i miss A line
#include <iostream>
#include <cmath>
using namespace std;

class studentre
{
public:
	
	double quiz1,quiz2;
	double midterm;
    double final;
    double average;
  
private:
	studentre();
	void getgrade(double,double,double,double);
	void getaverage(double);
	void display();
}
studentre::studentre()
{
	quiz1=0;
	quiz2=0;
	midterm=0;
    final=0;
    average=0;
}
void studentre::getgrade(double quiz1a, double quiz2a,double midterma,double finala)
{
	quiz1a=quiz1/10;
	quiz2a=quiz2/10;
	midterma=midterm/100;
	finala=final/100;
}
void studentre::getaverage(double average)
{
	average = ( (midterm / 100) * .25 ) + ( ( quiz1/10 ) * .125 ) + ( ( quiz2/10 ) * .125 ) + ( ( final/100 ) * .50);
}
void studentre::display()
{
	cout<< "Your quiz one is"<<quiz1<<endl;
	cout<< "Your second Quiz is"<<quiz2<<endl;
	cout<<" Your midterm is"<<midterm<<endl;
	cout<<" Your final is"<<final<<endl;
	cout<<" Your average is"<<average<<endl;
}
int main()
{
     cout<< "Enter first quiz mark: " << quiz1 <<endl;
     cin>>quiz1;
     cout<< "Enter second quiz mark: "<< quiz2<<endl;
     cin>>quiz2;
     cout<< "Enter midterm exam mark: "<<midterm<<endl;
     cin>>midterm;
     cout<< "Enter final exam mark: " << final<<endl;
     cin>>final;
     system ("pause");

    }

Was This Post Helpful? 0
  • +
  • -

#3 LaughingBelly  Icon User is offline

  • D.I.C Head

Reputation: 45
  • View blog
  • Posts: 102
  • Joined: 11-April 11

Re: Problem with Code for a grading program

Posted 06 February 2012 - 02:27 PM

what compiler are you using? Weird that it did not give you any file names or line numbers...

I recommend using a better compiler. Most modern compilers will tell you the line numbers where they think the error is occuring. These are not 100% accurate, but they do a much better job at it.

As for your errors, I would add a ; after the class declaration. This should sort the first error and potentially get rid of a couple of others too.

Edit: You probably pasted the error list from the IDE where it abstracts the line numbers because it shows where the error is when you click on the error message. If you are using such an IDE(VS?), it is simply a matter of following each error from the top. The errors for the most part are very descriptive. If you are having trouble understanding a specific one, you can tell us which one and we can explain what it means.

This post has been edited by LaughingBelly: 06 February 2012 - 02:29 PM

Was This Post Helpful? 0
  • +
  • -

#4 StormRonin  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 62
  • Joined: 27-May 10

Re: Problem with Code for a grading program

Posted 06 February 2012 - 02:30 PM

OK I compile it again and i get only grade.cpp(19): error C2533: 'studentre::{ctor}' : constructors not allowed a return type
Was This Post Helpful? 0
  • +
  • -

#5 LaughingBelly  Icon User is offline

  • D.I.C Head

Reputation: 45
  • View blog
  • Posts: 102
  • Joined: 11-April 11

Re: Problem with Code for a grading program

Posted 06 February 2012 - 02:32 PM

We'd have to see your new code to figure out why it thinks your constructor is returning something.

Remember, constructors return nothing. So dont even specify void as return type.
Was This Post Helpful? 0
  • +
  • -

#6 StormRonin  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 62
  • Joined: 27-May 10

Re: Problem with Code for a grading program

Posted 06 February 2012 - 02:35 PM

this is the new code that is having the problem
#include <iostream>
#include <cmath>
using namespace std;

class studentre
{
public:
	double quiz1,quiz2;
	double midterm;
    double final;
    double average;
private:
	studentre();
	void getgrade(double,double,double,double);
	void getaverage(double);
	void display();
}
studentre::studentre()
{
}
void studentre::getgrade(double quiz1a, double quiz2a,double midterma,double finala)
{
	quiz1a=quiz1/10;
	quiz2a=quiz2/10;
	midterma=midterm/100;
	finala=final/100;
}
void studentre::getaverage(double average)
{
	average = ( (midterm / 100) * .25 ) + ( ( quiz1/10 ) * .125 ) + ( ( quiz2/10 ) * .125 ) + ( ( final/100 ) * .50);
}
void studentre::display()
{
	cout<< "Your quiz one is"<<quiz1<<endl;
	cout<< "Your second Quiz is"<<quiz2<<endl;
	cout<<" Your midterm is"<<midterm<<endl;
	cout<<" Your final is"<<final<<endl;
	cout<<" Your average is"<<average<<endl;
}
int main()
{
	double quiz1,quiz2,midterm,final;

     cout<< "Enter first quiz mark: " << quiz1 <<endl;
     cin>>quiz1;
     cout<< "Enter second quiz mark: "<< quiz2<<endl;
     cin>>quiz2;
     cout<< "Enter midterm exam mark: "<<midterm<<endl;
     cin>>midterm;
     cout<< "Enter final exam mark: " << final<<endl;
     cin>>final;
     system ("pause");

 }

Was This Post Helpful? 0
  • +
  • -

#7 LaughingBelly  Icon User is offline

  • D.I.C Head

Reputation: 45
  • View blog
  • Posts: 102
  • Joined: 11-April 11

Re: Problem with Code for a grading program

Posted 06 February 2012 - 02:39 PM

you are still missing the ; after the class declaration.
Was This Post Helpful? 0
  • +
  • -

#8 StormRonin  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 62
  • Joined: 27-May 10

Re: Problem with Code for a grading program

Posted 06 February 2012 - 02:39 PM

thanks you for your help I found it
Was This Post Helpful? 0
  • +
  • -

#9 StormRonin  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 62
  • Joined: 27-May 10

Re: Problem with Code for a grading program

Posted 06 February 2012 - 03:11 PM

I know have problem having the numbers that i put in in the main go into the class
#include <iostream>
#include <cmath>
using namespace std;

class studentre
{
public:
	double quiz1,quiz2;
	double midterm;
    double final;
    double average;

	studentre();
	void getgrade(double,double,double,double);
	void getaverage(double);
	void display();
};
studentre::studentre()
{

}
void studentre::getgrade(double quiz1a, double quiz2a,double midterma,double finala)
{
	quiz1a=quiz1/10;
	quiz2a=quiz2/10;
	midterma=midterm/100;
	finala=final/100;
}
void studentre::getaverage(double average)
{
	average = ( (midterm / 100) * .25 ) + ( ( quiz1/10 ) * .125 ) + ( ( quiz2/10 ) * .125 ) + ( ( final/100 ) * .50);
}
void studentre::display()
{
	cout<< "Your quiz one is"<<quiz1<<endl;
	cout<< "Your second Quiz is"<<quiz2<<endl;
	cout<<" Your midterm is"<<midterm<<endl;
	cout<<" Your final is"<<final<<endl;
	cout<<" Your average is"<<average<<endl;
}
int main()
{
	studentre student;
	double quiz1,quiz2,midterm,final;
     cout<< "Enter first quiz mark: "<<endl;
     cin>>quiz1;
     cout<< "Enter second quiz mark: "<<endl;
     cin>>quiz2;
     cout<< "Enter midterm exam mark: "<<endl;
     cin>>midterm;
     cout<< "Enter final exam mark: " <<endl;
     cin>>final;
	 student.getgrade(quiz1,quiz2,midterm,final);
	 student.display();
     system ("pause");

 }

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1