Student grade report

reading records from a file

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 6203 Views - Last Post: 25 June 2009 - 12:57 PM Rate Topic: -----

#1 mb1980  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 67
  • Joined: 07-May 09

Student grade report

Post icon  Posted 25 June 2009 - 09:15 AM

Once again i am loosing my mind on this :

reading from a file :
876-54-3210
James Baker
55 66 77 88 99
Karen Chen
978-34-2300
45 55 65 75 85
345-21-0244
Pam Marange
53 63 73 83 93
219-87-4456
Markus Beck
95 95 95 95 95
654-76-8976
Boris Becker
65 74 32 99 76
888-765-4532
Micheal Jackson
90 87 69 99 87
765-32-5679
Clint Eastwood
34 24 76 99 80
987-54-2343
Hans Wilhelm
76 21 67 66 99
987-90-9977
Hanna Montana
65 45 98 99 56
123-34-7654
Tina Turner
76 85 94 30 99
765-09-3456
Micheal Jordan
78 98 90 99 98
654-90-3214
Andrea Hills
56 45 36 76 87
900-87-6524
Martin Sheen
99 89 78 67 65
768-55-4321
Bud Spencer
55 90 78 80 89
645-90-8765
Terence Hill
78 91 94 98 99
763-92-0987
Jed Houston
98 90 87 54 60
764-87-5467
Papa Kaka
73 96 89 74 30

i need to output:

Student# Student Name Mt FL P1 P2 CP CGN CGL

-------------------------------------------------------------------------------------------------



876-54-3210 John Baker 98 92 99 98 80 94.90 A

978-34-2300 Karen Chen 85 75 98 95 99 88.50 B

345-21-0244 Pam Marange 60 65 80 50 70 64.25 D

.

.

.

.

.

Total number of students processed = 15

Class average for this course = 86.66


this is my code:

#include <fstream>
#include <iomanip>
#include <cstdlib>

using namespace std;

class Report
{
private:
	char id [12];
	char name [20];
	double midterm, final, p1, p2, p3;
	ifstream in_file;

public:
	Report ();
	~Report ();

	void print_heading();
	void read_input();
	int calc_grade();
	char convert_grade(int);
	void display_result(char, int);
	ifstream & get();

};

Report::Report()
{ in_file.open ("C://Documents and Settings//Markus//Desktop//P3_input.DAT");

if (!in_file)
{
	cerr<<"Error:File could not be opened"<<endl;
	cerr<<"Program terminating"<<endl;
	exit(1);
}

void Report::read_input()
{ 
	in_file.getline(id, 12);
	in_file.getline(name, 20);
	in_file>>midterm>>f1>>p1>>p2>>cp;
	in_file.get();
};

int Report::calc_grade()

	int course_grade;
	course_grade int=(midterm*0,25+f1*0,25+p1*0,20+p2*0,20+cp*0,10);
	return course_grade;
};


char Report::convert_grade(int_grade)
{
	if (grade>=90&&grade<=100)
		return 'A';
	else if (grade>=80&&grade<90)
		return 'B';
	else if (grade>=70&&grade<80)
		return 'C';
	else if (grade>=60&&grade<70)
		return 'D';
	else if (grade>=50&&grade<60)
		return 'E';
	else if (grade>=40&&grade<=50)
		return 'F';

};

char Report::display_result (char letter, int grade)
{
	cout << setw(5)<< "Student#" << setw(15) << "Student Name" << setw(5) << "MT" << setw(5) << "FL"
	<< setw(5) << "P1" << setw(5) << "P2" << setw(5) << "CP" << setw(5)<< "CGN" << setw (5)<< "CGL"<<endl;
	cout<<"-----------------------------------------------------------------------------------------"<<

	cout<< setw(12)<<id<<setw(20)<<name<<setw(3)<<midterm<<setw(3)<<final<<setw(3)<<p1<<setw(3)<<p2<<
	setw(3)<<course_grade<<setw(3)<<grade<<endl;





};

ifstream&report::get()
{
	return in_file;
}

Report::~Report()
{
	in_file.close();
}

int main()
{
	int grade;
	char letter;
	Report s1;
	s1.print.heading();
	ifstream&read_file=s1.get();
	s1.read_input();
	while (!read_file.eof());
	{
		grade=s1.calc_grade();
		letter=s1.convert_grade(grade);
		s1.display_result (letter, grade);
		s1.read_input();
	}









it is not even compiling, i have to turn this in tomorrow and have finals also about to loose my mind here, i will even pay to get this fixed i cannot think straight anymore.

Is This A Good Question/Topic? 0
  • +

Replies To: Student grade report

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1642
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Student grade report

Posted 25 June 2009 - 09:21 AM

Since it wont compile what errors are you getting? Knowing this will help us know where to look and come up with some suggestions faster :)
Was This Post Helpful? 0
  • +
  • -

#3 prabh  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 3
  • View blog
  • Posts: 381
  • Joined: 27-December 08

Re: Student grade report

Posted 25 June 2009 - 09:24 AM

what error you got


because your code is causing
Tsunamis in my Mind
Was This Post Helpful? 0
  • +
  • -

#4 mb1980  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 67
  • Joined: 07-May 09

Re: Student grade report

Posted 25 June 2009 - 09:26 AM

OMG is it that bad?

------ Build started: Project: Assignment3, Configuration: Debug Win32 ------
Compiling...
Report.cpp
..\..\..\Report.cpp(33) : error C2065: 'cerr' : undeclared identifier
..\..\..\Report.cpp(34) : error C2065: 'cerr' : undeclared identifier
..\..\..\Report.cpp(39) : error C2601: 'Report::read_input' : local function definitions are illegal
..\..\..\Report.cpp(29): this line contains a '{' which has not yet been matched
..\..\..\Report.cpp(48) : error C2144: syntax error : 'int' should be preceded by ';'
..\..\..\Report.cpp(48) : error C2761: 'int Report::calc_grade(void)' : member function redeclaration not allowed
..\..\..\Report.cpp(49) : error C2144: syntax error : 'int' should be preceded by ';'
..\..\..\Report.cpp(49) : error C2513: 'int' : no variable declared before '='
..\..\..\Report.cpp(49) : error C2065: 'f1' : undeclared identifier
..\..\..\Report.cpp(49) : error C2065: 'cp' : undeclared identifier
..\..\..\Report.cpp(50) : error C2534: 'Report' : constructor cannot return a value
..\..\..\Report.cpp(8) : see declaration of 'Report'
..\..\..\Report.cpp(50) : error C2562: 'Report::Report' : 'void' function returning a value
..\..\..\Report.cpp(16) : see declaration of 'Report::Report'
..\..\..\Report.cpp(42) : error C2065: 'f1' : undeclared identifier
..\..\..\Report.cpp(42) : error C2065: 'cp' : undeclared identifier
..\..\..\Report.cpp(54) : error C2065: 'int_grade' : undeclared identifier
..\..\..\Report.cpp(55) : error C2448: 'Report::convert_grade' : function-style initializer appears to be a function definition
..\..\..\Report.cpp(72) : error C2556: 'char Report::display_result(char,int)' : overloaded function differs only by return type from 'void Report::display_result(char,int)'
..\..\..\Report.cpp(23) : see declaration of 'Report::display_result'
..\..\..\Report.cpp(72) : error C2371: 'Report::display_result' : redefinition; different basic types
..\..\..\Report.cpp(23) : see declaration of 'Report::display_result'
..\..\..\Report.cpp(73) : error C2065: 'cout' : undeclared identifier
..\..\..\Report.cpp(75) : error C2065: 'cout' : undeclared identifier
..\..\..\Report.cpp(77) : error C2065: 'cout' : undeclared identifier
..\..\..\Report.cpp(78) : error C2065: 'course_grade' : undeclared identifier
..\..\..\Report.cpp(86) : error C2653: 'report' : is not a class or namespace name
..\..\..\Report.cpp(88) : error C2065: 'in_file' : undeclared identifier
..\..\..\Report.cpp(101) : error C2039: 'print' : is not a member of 'Report'
..\..\..\Report.cpp(8) : see declaration of 'Report'
..\..\..\Report.cpp(101) : error C2228: left of '.heading' must have class/struct/union
..\..\..\Report.cpp(108) : error C2264: 'Report::display_result' : error in function definition or declaration; function not called
..\..\..\Report.cpp(117) : fatal error C1075: end of file found before the left brace '{' at '..\..\..\Report.cpp(97)' was matched
Build log was saved at "file://c:\Documents and Settings\Markus\Desktop\Workspacefiles C++\Assignment3\Assignment3\Debug\BuildLog.htm"
Assignment3 - 27 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Was This Post Helpful? 0
  • +
  • -

#5 prabh  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 3
  • View blog
  • Posts: 381
  • Joined: 27-December 08

Re: Student grade report

Posted 25 June 2009 - 09:32 AM

Dude
read those errors you are missing many things
your identifiers are not correctly declared
you missed those semicolons
and many more

Take some time

give us the errors which get after fixing these errors
Was This Post Helpful? 0
  • +
  • -

#6 mb1980  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 67
  • Joined: 07-May 09

Re: Student grade report

Posted 25 June 2009 - 09:56 AM

i am not a programmer can u show me in the code what i did wrong?
PLEASE
Was This Post Helpful? 0
  • +
  • -

#7 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1112
  • View blog
  • Posts: 4,619
  • Joined: 09-June 09

Re: Student grade report

Posted 25 June 2009 - 10:04 AM

your missing
 #include <iostream>
for starters
Was This Post Helpful? 1
  • +
  • -

#8 mb1980  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 67
  • Joined: 07-May 09

Re: Student grade report

Posted 25 June 2009 - 10:14 AM

#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdlib>

using namespace std;

class Report
{
private:
	char id [12];
	char name [20];
	double midterm, final, p1, p2, p3;
	ifstream in_file;

public:
	Report ();
	~Report ();

	void print_heading();
	void read_input();
	int calc_grade();
	char convert_grade(int);
	void display_result(char, int);
	ifstream & get();

};

Report::Report()
{ in_file.open ("C://Documents and Settings//Markus//Desktop//P3_input.DAT");

if (!in_file)
{
	cerr<<"Error:File could not be opened"<<endl;
	cerr<<"Program terminating"<<endl;
	exit(1);
}
}
void Report::read_input()
{ 
	in_file.getline(id, 12);
	in_file.getline(name, 20);
	in_file>>midterm>>f1>>p1>>p2>>cp;
	in_file.get();
};

int Report::calc_grade()

	int course_grade;
	course_grade int=(midterm*0,25+f1*0,25+p1*0,20+p2*0,20+cp*0,10);
	return course_grade;
};


char Report::convert_grade(int_grade)
{
	if (grade>=90&&grade<=100)
		return 'A';
	else if (grade>=80&&grade<90)
		return 'B';
	else if (grade>=70&&grade<80)
		return 'C';
	else if (grade>=60&&grade<70)
		return 'D';
	else if (grade>=50&&grade<60)
		return 'E';
	else if (grade>=40&&grade<=50)
		return 'F';

};

char Report::display_result (char letter, int grade)
{
	cout << setw(5)<< "Student#" << setw(15) << "Student Name" << setw(5) << "MT" << setw(5) << "FL"
	<< setw(5) << "P1" << setw(5) << "P2" << setw(5) << "CP" << setw(5)<< "CGN" << setw (5)<< "CGL"<<endl;
	cout<<"-----------------------------------------------------------------------------------------"<<

	cout<< setw(12)<<id<<setw(20)<<name<<setw(3)<<midterm<<setw(3)<<final<<setw(3)<<p1<<setw(3)<<p2<<
	setw(3)<<course_grade<<setw(3)<<grade<<endl;





};

ifstream&report::get()
{
	return in_file;
}

Report::~Report()
{
	in_file.close();
}

int main()
{
	int grade;
	char letter;
	Report s1;
	s1.print.heading();
	ifstream&read_file=s1.get();
	s1.read_input();
	while (!read_file.eof());
	{
		grade=s1.calc_grade();
		letter=s1.convert_grade(grade);
		s1.display_result (letter, grade);
		s1.read_input();
	}




still getting 27 errors
Was This Post Helpful? 0
  • +
  • -

#9 kmangold  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 11
  • View blog
  • Posts: 167
  • Joined: 24-June 09

Re: Student grade report

Posted 25 June 2009 - 10:20 AM

View PostPsychoCoder, on 25 Jun, 2009 - 10:21 AM, said:

Since it wont compile what errors are you getting? Knowing this will help us know where to look and come up with some suggestions faster :)


Every update you make to your code, if you still have errors, you need to repost the errors you are getting. Fixing one error could fix a few others but bring up new ones as well.
Was This Post Helpful? 0
  • +
  • -

#10 mb1980  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 67
  • Joined: 07-May 09

Re: Student grade report

Posted 25 June 2009 - 10:26 AM

------ Build started: Project: Assignment3, Configuration: Debug Win32 ------
Compiling...
Report.cpp
..\..\..\Report.cpp(43) : error C2065: 'f1' : undeclared identifier
..\..\..\Report.cpp(43) : error C2065: 'cp' : undeclared identifier
..\..\..\Report.cpp(49) : error C2144: syntax error : 'int' should be preceded by ';'
..\..\..\Report.cpp(49) : error C2761: 'int Report::calc_grade(void)' : member function redeclaration not allowed
..\..\..\Report.cpp(50) : error C2144: syntax error : 'int' should be preceded by ';'
..\..\..\Report.cpp(50) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
..\..\..\Report.cpp(50) : error C2086: 'int course_grade' : redefinition
..\..\..\Report.cpp(49) : see declaration of 'course_grade'
..\..\..\Report.cpp(50) : error C2513: 'int' : no variable declared before '='
..\..\..\Report.cpp(50) : error C2065: 'midterm' : undeclared identifier
..\..\..\Report.cpp(50) : error C2065: 'f1' : undeclared identifier
..\..\..\Report.cpp(50) : error C2065: 'p1' : undeclared identifier
..\..\..\Report.cpp(50) : error C2065: 'p2' : undeclared identifier
..\..\..\Report.cpp(50) : error C2065: 'cp' : undeclared identifier
..\..\..\Report.cpp(51) : error C2059: syntax error : 'return'
..\..\..\Report.cpp(52) : error C2059: syntax error : '}'
..\..\..\Report.cpp(52) : error C2143: syntax error : missing ';' before '}'
..\..\..\Report.cpp(52) : error C2059: syntax error : '}'
..\..\..\Report.cpp(55) : error C2065: 'int_grade' : undeclared identifier
..\..\..\Report.cpp(56) : error C2448: 'Report::convert_grade' : function-style initializer appears to be a function definition
..\..\..\Report.cpp(73) : error C2556: 'char Report::display_result(char,int)' : overloaded function differs only by return type from 'void Report::display_result(char,int)'
..\..\..\Report.cpp(24) : see declaration of 'Report::display_result'
..\..\..\Report.cpp(73) : error C2371: 'Report::display_result' : redefinition; different basic types
..\..\..\Report.cpp(24) : see declaration of 'Report::display_result'
..\..\..\Report.cpp(87) : error C2653: 'report' : is not a class or namespace name
..\..\..\Report.cpp(89) : error C2065: 'in_file' : undeclared identifier
..\..\..\Report.cpp(102) : error C2039: 'print' : is not a member of 'Report'
..\..\..\Report.cpp(9) : see declaration of 'Report'
..\..\..\Report.cpp(102) : error C2228: left of '.heading' must have class/struct/union
..\..\..\Report.cpp(109) : error C2264: 'Report::display_result' : error in function definition or declaration; function not called
..\..\..\Report.cpp(118) : fatal error C1004: unexpected end-of-file found
Build log was saved at "file://c:\Documents and Settings\Markus\Desktop\Workspacefiles C++\Assignment3\Assignment3\Debug\BuildLog.htm"
Assignment3 - 27 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Was This Post Helpful? 0
  • +
  • -

#11 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: Student grade report

Posted 25 June 2009 - 10:54 AM

Quote

i am not a programmer can u show me in the code what i did wrong?
PLEASE
This is code, and by working on code, you are a programmer. A beginning perhaps, but nonetheless, you must act like one. Stop begging, and start working out things. It is frustrating, but reacting with panic and frustration won't help.

Quote

still getting 27 errors
As advice in the future, don't write code like you write English essays. Don't write out a 100 lines of code and then check if it all works out in the end. No one does this. Make a very small change or addition. Recompile. Check if it behaves as expected. Repeat. Small changes and fast feedback is manageable. 27 errors is troublesome.

Also, I can't stress this enough: Read the errors. Don't count them. No doubt it's difficult to comprehend them with limited knowledge and experience, but try. If you just stare at the entire error list, you won't know what to do. Look at the first error, tackle that first. Then recompile and look at the errors again. Tackle the first one again, and so on.

Your code isn't too horribly indented, but it's non consistent enough, and it makes spotting a few errors harder. Keep indentation clean. You pay for it in this kind of frustration if you don't.

The first thing you want to do right now is get the some missing/extra brace and semicolon issues out of the way. They can propagate a lot of strange errors. I've reposted your code, with comments. Search for "FIXME" in the code to quickly find them.

#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdlib>

using namespace std;

class Report
{
private:
	char id [12];
	char name [20];
	double midterm, final, p1, p2, p3;
	ifstream in_file;

public:
	Report ();
	~Report ();

	void print_heading();
	void read_input();
	int calc_grade();
	char convert_grade(int);
	void display_result(char, int);
	ifstream & get();

};

// NOTE: Bad indentation. Nothing wrong here, but if you did make a mistake, it would be harder to see.
Report::Report()
{ in_file.open ("C://Documents and Settings//Markus//Desktop//P3_input.DAT");

if (!in_file)
{
	cerr<<"Error:File could not be opened"<<endl;
	cerr<<"Program terminating"<<endl;
	// NOTE: Bad programming design, but not really worth caring about in this assignment I suppose.
	exit(1);
}
}
void Report::read_input()
{
	in_file.getline(id, 12);
	in_file.getline(name, 20);
	in_file>>midterm>>f1>>p1>>p2>>cp;
	in_file.get();
}; // FIXME: Extra semicolon. Look at your notes carefully to check for syntax in functions. There is no semicolon at the end.

int Report::calc_grade()
// FIXME: Forget an opening brace for this function?
// NOTE: Bad indentation makes it harder to see the problem
int course_grade;
course_grade int=(midterm*0,25+f1*0,25+p1*0,20+p2*0,20+cp*0,10);
return course_grade;
}; //FIXME: Extra semicolon.


char Report::convert_grade(int_grade)
{
	if (grade>=90&&grade<=100)
		return 'A';
	else if (grade>=80&&grade<90)
		return 'B';
	else if (grade>=70&&grade<80)
		return 'C';
	else if (grade>=60&&grade<70)
		return 'D';
	else if (grade>=50&&grade<60)
		return 'E';
	else if (grade>=40&&grade<=50)
		return 'F';

}; //FIXME: Extra semicolon

char Report::display_result (char letter, int grade)
{
	cout << setw(5)<< "Student#" << setw(15) << "Student Name" << setw(5) << "MT" << setw(5) << "FL"
		<< setw(5) << "P1" << setw(5) << "P2" << setw(5) << "CP" << setw(5)<< "CGN" << setw (5)<< "CGL"<<endl;
	cout<<"-----------------------------------------------------------------------------------------"<<

		cout<< setw(12)<<id<<setw(20)<<name<<setw(3)<<midterm<<setw(3)<<final<<setw(3)<<p1<<setw(3)<<p2<<
		setw(3)<<course_grade<<setw(3)<<grade<<endl;
// NOTE: Cut out the extra spacing here, makes it hard to read




}; // FIXME: Extra semicolon. 

ifstream&report::get()
{
	return in_file;
}

Report::~Report()
{
	in_file.close();
}

int main()
{
	int grade;
	char letter;
	Report s1;
	s1.print.heading();
	ifstream&read_file=s1.get();
	s1.read_input();
	while (!read_file.eof());
	{
		grade=s1.calc_grade();
		letter=s1.convert_grade(grade);
		s1.display_result (letter, grade);
		s1.read_input();
	}
// FIXME: Missing closing brace. Easy to spot because you indented well.


Was This Post Helpful? 1
  • +
  • -

#12 mb1980  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 67
  • Joined: 07-May 09

Re: Student grade report

Posted 25 June 2009 - 11:45 AM

thank you for your help i will know for next time, i changed some stuff around and was down to 9 errors but now i am back to 20.

#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdlib>

using namespace std;

class Report
{
private:
	char id [12];
	char name [20];
	double midterm, final,f1, p1, p2, p3,cp;
	ifstream in_file;

public:
	Report ();
	~Report ();

	void print_heading();
	void read_input();
	int calc_grade();
	char convert_grade(int);
	void display_result(char, int);
	ifstream & get();

};


Report::Report()
	{ in_file.open ("C://Documents and Settings//Markus//Desktop//P3_input.DAT");

		if (!in_file)
			{
				cerr<<"Error:File could not be opened"<<endl;
				cerr<<"Program terminating"<<endl;
			 
			 exit(1);
			}
}
void Report::read_input()
{
	in_file.getline(id, 12);
	in_file.getline(name, 20);
	in_file>>midterm>>f1>>p1>>p2>>cp;
	in_file.get();
} 

int Report::calc_grade()
{// FIXME: Forget an opening brace for this function?
// NOTE: Bad indentation makes it harder to see the problem
int course_grade;
course_grade=(midterm*0,25+f1*0,25+p1*0,20+p2*0,20+cp*0,10);
return course_grade;
}

char Report::convert_grade(int)
{
	if (course_grade>=90&&grade<=100)
		return 'A';
	else if (course_grade>=80&&grade<90)
		return 'B';
	else if (course_grade>=70&&grade<80)
		return 'C';
	else if (course_grade>=60&&grade<70)
		return 'D';
	else if (course_grade>=50&&grade<60)
		return 'E';
	else if (course_grade>=40&&grade<=50)
		return 'F';

} 

char Report::display_result (char letter, int grade)
{
	cout << setw(5)<< "Student#" << setw(15) << "Student Name" << setw(5) << "MT" << setw(5) << "FL"
		<< setw(5) << "P1" << setw(5) << "P2" << setw(5) << "CP" << setw(5)<< "CGN" << setw (5)<< "CGL"<<endl;
	cout<<"-----------------------------------------------------------------------------------------"<<

		cout<< setw(12)<<id<<setw(20)<<name<<setw(3)<<midterm<<setw(3)<<final<<setw(3)<<p1<<setw(3)<<p2<<
		setw(3)<<course_grade<<setw(3)<<grade<<endl;


} 

ifstream&report::get()
{
	return in_file;
}

Report::~Report()
{
	in_file.close();
}

int main()
{
	int grade;
	char letter;
	Report s1;
	s1.print.heading();
	ifstream&read_file=s1.get();
	s1.read_input();
	while (!read_file.eof());
	{
		grade=s1.calc_grade();
		letter=s1.convert_grade(grade);
		s1.display_result (letter, grade);
		s1.read_input();
	}
}



..\..\..\Report.cpp(61) : error C2065: 'course_grade' : undeclared identifier
..\..\..\Report.cpp(61) : error C2065: 'grade' : undeclared identifier
..\..\..\Report.cpp(63) : error C2065: 'course_grade' : undeclared identifier
..\..\..\Report.cpp(63) : error C2065: 'grade' : undeclared identifier
..\..\..\Report.cpp(65) : error C2065: 'course_grade' : undeclared identifier
..\..\..\Report.cpp(65) : error C2065: 'grade' : undeclared identifier
..\..\..\Report.cpp(67) : error C2065: 'course_grade' : undeclared identifier
..\..\..\Report.cpp(67) : error C2065: 'grade' : undeclared identifier
..\..\..\Report.cpp(69) : error C2065: 'course_grade' : undeclared identifier
..\..\..\Report.cpp(69) : error C2065: 'grade' : undeclared identifier
..\..\..\Report.cpp(71) : error C2065: 'course_grade' : undeclared identifier
..\..\..\Report.cpp(71) : error C2065: 'grade' : undeclared identifier
..\..\..\Report.cpp(77) : error C2556: 'char Report::display_result(char,int)' : overloaded function differs only by return type from 'void Report::display_result(char,int)'
..\..\..\Report.cpp(25) : see declaration of 'Report::display_result'
..\..\..\Report.cpp(77) : error C2371: 'Report::display_result' : redefinition; different basic types
..\..\..\Report.cpp(25) : see declaration of 'Report::display_result'
..\..\..\Report.cpp(83) : error C2065: 'course_grade' : undeclared identifier
..\..\..\Report.cpp(88) : error C2653: 'report' : is not a class or namespace name
..\..\..\Report.cpp(90) : error C2065: 'in_file' : undeclared identifier
..\..\..\Report.cpp(103) : error C2039: 'print' : is not a member of 'Report'
..\..\..\Report.cpp(10) : see declaration of 'Report'
..\..\..\Report.cpp(103) : error C2228: left of '.heading' must have class/struct/union
..\..\..\Report.cpp(110) : error C2264: 'Report::display_result' : error in function definition or declaration; function not called
Build log was saved at "file://c:\Documents and Settings\Markus\Desktop\Workspacefiles C++\Assignment3\Assignment3\Debug\BuildLog.htm"
Assignment3 - 20 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Was This Post Helpful? 0
  • +
  • -

#13 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: Student grade report

Posted 25 June 2009 - 12:15 PM

Quote

i changed some stuff around and was down to 9 errors but now i am back to 20.
Sure. When I gave you the annotated code, I only noted mistakes with semicolons and braces, which can be time consuming to identify for beginners. That was a bit generous of me, but I realized you were panicking a bit.

Freebies are over though. As I noted, you have to read the error, and fix one by one. Fix the first, repeat the compile, fix the first, repeat the compile, until you fix all the code. Counting errors is rather pointless. It gives no clear indication of correctness (a simple mistake can spawn a huge mess of errors).

Apply some logic here. The first error you have is .\..\..\Report.cpp(61) : error C2065: 'course_grade' : undeclared identifier. That's an error message that tells you: In Report.cpp, on line 61...you should have a decent code editor and thus be able to find line 61. Then it says error, and gives an identification for this error. C2065 is a type of error, and this identification makes it easy to Google or lookup. You don't really need to care about this identification. Now for the rest of the message. 'course_grade' : undeclared identifier. Identifier is the technical way of saying a name for something. So it's saying course_grade, this particular identifier, has not been declared before.

Where did you pull this name out of? Thin air? Of course not, but you made a mistake that causes this error. Look at line 61, and the surrounding code in question.

char Report::convert_grade(int)
{
	if (course_grade>=90&&grade<=100) //LINE 61
		return 'A';
	else if (course_grade>=80&&grade<90)
		return 'B';



What's wrong here? Line 61 looks ok, but it's complaining about not knowing what course_grade stands for. Well, it's the name of that parameter you passed into the function. It can be found at convert_grade(int). Oh wait, you left out the name. There's the problem.

Now, apply this kind of investigative process to every error you come across.
Was This Post Helpful? 0
  • +
  • -

#14 mb1980  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 67
  • Joined: 07-May 09

Re: Student grade report

Posted 25 June 2009 - 12:35 PM

What name?
U mean i forgot to declare the name course_grade?
Was This Post Helpful? 0
  • +
  • -

#15 mb1980  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 67
  • Joined: 07-May 09

Re: Student grade report

Posted 25 June 2009 - 12:45 PM

here is the same assignment just a little different:
#include <fstream>
#include <iomanip>
#include <cstdlib>
#include <iostream>

using namespace std;

class Report
{
private:
	char id [12];
	char name [20];
	double midterm, f1, p1, p2, p3,cp;
	ifstream in_file;

public:
	Report ();
	~Report ();

	void print_heading();
	void read_input();
	int calc_grade();
	char convert_grade(int);
	void display_result(char, int);
	ifstream & get();

};

Report::Report()
{
	in_file.open ("C://Documents and Settings//Markus//Desktop//P3_input.DAT");

		if (!in_file)
	{
		cerr<<"Error:File could not be opened"<<endl;
		cerr<<"Program terminating"<<endl;
		exit(1);
	}
}

void Report::read_input()
{ 
	in_file.getline(id, 12);
	in_file.getline(name, 20);
	in_file>>midterm>>f1>>p1>>p2>>cp;
	in_file.get();
}

int Report::calc_grade()
{
	int course_grade;

	course_grade = (int)((midterm*0.25)+(f1*0.25)+(p1*0.20)+(p2*0.20)+(cp*0.10));

	return course_grade;
}

char Report::convert_grade(int grade)
{
	if (grade>=90&&grade<=100)
		return 'A';
	else if (grade>=80&&grade<90)
		return 'B';
	else if (grade>=70&&grade<80)
		return 'C';
	else if (grade>=60&&grade<70)
		return 'D';
	else if (grade>=50&&grade<60)
		return 'E';
	else if (grade>=40&&grade<=50)
		return 'F';
}

void Report::display_result (char letter, int grade)
{
	cout << setw(5)<< "Student#" << setw(15) << "Student Name" << setw(5)
		<< "MT" << setw(5) << "FL"
		<< setw(5) << "P1" << setw(5) << "P2" << setw(5) 
	<< "CP" << setw(5)<< "CGN" << setw (5)<< "CGL"<<endl;
		cout<<"-----------------------------------------------------------------------------------------";

	//cout<< setw(12)<<id<<setw(20)<<name<<setw(3)<<midterm<<setw(3)<<f1<<setw(3)<<p1<<setw(3)<<p2<<
	//setw(3)<<letter<<setw(3)<<grade<<endl;
}

ifstream &Report::get()
{
	return in_file;
}

Report::~Report()
{
	in_file.close();
}

int main()
{
	int grade;
	char letter;
	
	Report s1;
	s1.print_heading();
	ifstream &read_file=s1.get();
	s1.read_input();
	
	while (!read_file.eof())
	{
		grade=s1.calc_grade();
		letter=s1.convert_grade(grade);
		s1.display_result (letter, grade);
		s1.read_input();

		cout<<setw(3)<<letter<<setw(3)<<grade<<endl;
	}
return 0;
}




gives me this error message:

------ Build started: Project: 3, Configuration: Debug Win32 ------
Linking...
3.obj : error LNK2028: unresolved token (0A000339) "public: void __thiscall Report::print_heading(void)" (?print_heading@Report@@$$FQAEXXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
3.obj : error LNK2019: unresolved external symbol "public: void __thiscall Report::print_heading(void)" (?print_heading@Report@@$$FQAEXXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
C:\Documents and Settings\Markus\Desktop\Workspacefiles C++\3\Debug\3.exe : fatal error LNK1120: 2 unresolved externals
Build log was saved at "file://c:\Documents and Settings\Markus\Desktop\Workspacefiles C++\3\3\Debug\BuildLog.htm"
3 - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

i have no idea what that means and if i click on the error message it does not point me to the mistake either.???
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2