I dunno what I did wrong with my program but I am getting a bunch of errors is converting letter to number...could anyone take a look....

#include <iostream>
#include <string>
using namespace std;
string Get_Name_and_Num_Classes(string name, int classes);
double Calculate_GPA(char grade, int count);
void Get_Letter_Grade(char grade);
double Convert_Let_to_Num();
void Print_Results(string name, double gpa);

int main()
{
	string name, xxx;
	int count = 1;
	int classes;
	char grade;
	double gpa;

	cout << "Programmed by Jim Johnson";
	cout << endl << endl << "Type xxx for the name to Exit";

	do
	{
		cout << endl << endl << "Enter the student's last name: ";
		name = Get_Name_and_Num_Classes(name, classes);

		while (name != "xxx")
		{
			cout << endl << "How many classes taken: ";
			classes = Get_Name_and_Num_Classes(name, classes);

		}while (count <= classes)
			
		cout << endl << endl << "Enter letter grade " << count << ": ";
		grade = Get_Letter_Grade(grade);
		count ++;
		
		gpa = Calculate_GPA(grade, count);

		Print_Results(name, gpa);
	}while (name != "xxx");

	return 0;
}

void Get_Letter_Grade(char grade)
{
	
cin >> grade;
		
	
}

double Calculate_GPA()
{
	int total_grades;
	double gpa;

	total_grades = 
	
	return gpa;

}

string Convert_Let_to_Num(char grade)
{
	int number;
	if ((char == 'a') || (char == 'A'));
	{
		number = 4;
	}
	if ((char == 'b') || (char == 'B'));
	{
		number = 3;
	}
	if ((char == 'c') || (char == 'C'));
	{
		number = 2;
	}
	if ((char == 'd') || (char == 'D'));
	{
		number = 1;
	}
	if ((char == 'f') || (char == 'F'));
	{
		number = 0;
	}
	return (number);
}

void Print_Results(string name, double gpa)
{
	cout << "Student " << name << " has a semester GPA of " << gpa;
}

all my errors but just worried about convert letter to number(i think it must be something small so thinkin outside the box)...if anyone has ideas please let me know.....

1>------ Build started: Project: Project 04, Configuration: Debug Win32 ------
1>Compiling...
1>P04.cpp
1>c:\documents and settings\don & diane kruep\desktop\project 04\p04.cpp(33) : error C2440: '=' : cannot convert from 'std::string' to 'int'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>c:\documents and settings\don & diane kruep\desktop\project 04\p04.cpp(38) : error C2440: '=' : cannot convert from 'void' to 'char'
1> Expressions of type void cannot be converted to other types
1>c:\documents and settings\don & diane kruep\desktop\project 04\p04.cpp(64) : error C2059: syntax error : 'return'
1>c:\documents and settings\don & diane kruep\desktop\project 04\p04.cpp(71) : error C2143: syntax error : missing ')' before '=='
1>c:\documents and settings\don & diane kruep\desktop\project 04\p04.cpp(71) : error C2059: syntax error : '=='
1>c:\documents and settings\don & diane kruep\desktop\project 04\p04.cpp(71) : error C2059: syntax error : ')'
1>c:\documents and settings\don & diane kruep\desktop\project 04\p04.cpp(75) : error C2143: syntax error : missing ')' before '=='
1>c:\documents and settings\don & diane kruep\desktop\project 04\p04.cpp(75) : error C2059: syntax error : '=='
1>c:\documents and settings\don & diane kruep\desktop\project 04\p04.cpp(75) : error C2059: syntax error : ')'
1>c:\documents and settings\don & diane kruep\desktop\project 04\p04.cpp(79) : error C2143: syntax error : missing ')' before '=='
1>c:\documents and settings\don & diane kruep\desktop\project 04\p04.cpp(79) : error C2059: syntax error : '=='
1>c:\documents and settings\don & diane kruep\desktop\project 04\p04.cpp(79) : error C2059: syntax error : ')'
1>c:\documents and settings\don & diane kruep\desktop\project 04\p04.cpp(83) : error C2143: syntax error : missing ')' before '=='
1>c:\documents and settings\don & diane kruep\desktop\project 04\p04.cpp(83) : error C2059: syntax error : '=='
1>c:\documents and settings\don & diane kruep\desktop\project 04\p04.cpp(83) : error C2059: syntax error : ')'
1>c:\documents and settings\don & diane kruep\desktop\project 04\p04.cpp(87) : error C2143: syntax error : missing ')' before '=='
1>c:\documents and settings\don & diane kruep\desktop\project 04\p04.cpp(87) : error C2059: syntax error : '=='
1>c:\documents and settings\don & diane kruep\desktop\project 04\p04.cpp(87) : error C2059: syntax error : ')'
1>c:\documents and settings\don & diane kruep\desktop\project 04\p04.cpp(91) : error C2664: 'std::basic_string<_Elem,_Traits,_Ax>::basic_string(std::basic_string<_Elem,_Traits,_Ax>::_Has_debug_it)' : cannot convert parameter 1 from 'int' to 'std::basic_string<_Elem,_Traits,_Ax>::_Has_debug_it'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> Constructor for struct 'std::basic_string<_Elem,_Traits,_Ax>::_Has_debug_it' is declared 'explicit'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1>Build log was saved at "file://c:\Documents and Settings\Don & Diane Kruep\Desktop\Project 04\Debug\BuildLog.htm"
1>Project 04 - 19 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

instructions for the functions......

• Convert_Let_to_Num – Takes in a letter grade and converts it to its number equivalent (A–4, B–3, C–2, D–1, F–0) It should return the number equivalent

Recommended Answers

All 6 Replies

Line 59 is not finished.

void Get_Letter_Grade(char grade) does not return anything. It should be of some type other than 'void'

i know that is something I am still working on...could that be the reason for all the errors?

What I cant seem to understand is that in ur if statement u have declared grade as ur char and again u use statement like this if((char == 'A') || (char == 'a')) instead of if((grade == 'A') || (grade == 'a')) and you close ur IF statements before you can execute something inside them.... does it work like that... Just asking I dont know

i know that is something I am still working on...could that be the reason for all the errors?

You need to comment lines out that are only half-complete because it can play havoc with the compiler.

What I cant seem to understand is that in ur if statement u have declared grade as ur char and again u use statement like this if((char == 'A') || (char == 'a')) instead of if((grade == 'A') || (grade == 'a')) and you close ur IF statements before you can execute something inside them.... does it work like that... Just asking I dont know

No, it doesn't work like that. "char" is a reserved word and thus cannot be used as a variable name. If you look at the syntax highlighting, "char" is in purple, meaning that C++ has a special meaning for it and it is thus inadvisable if not completely impossible to use it as a variable name. Variable names are/should be in black (i.e. not hightlighted). The error messages show that C++ is not interpreting "char" as a variable. The OP needs to change the word "char" to the relevant variable name, which is, as you pointed out, "grade". You are also correct that the "if" statements are being closed too quickly. The semicolons need to be deleted.

Thanx man.... I still have a long way to go but at least with ur help guyz Im getting there slowly but surely... Ok now let me not make the problem mine.... Im just here to learn right????

haha yea what was I thinkin I know what I meant to do and that was not it...

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.