Convert_Let_to_Num needs the value of grade entered in from Get_Letter_Grade. As it's written now, it is always evaluating grade = ' ' (line 85) which is false for every condition - so the function is going to return 0 every time.

Just making sure I am doing iy right...was kinda confused how you explained it...if this is right shouldnt i add the parameter classes in convert let to num......

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

int main()
{
	string name;
	int sum = 0, number = 0;
	int classes = ' ';
	char grade = ' ';
	double gpa = 0.0;

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

	while (name != "xxx")
	{
		classes = Get_Name_and_Num_Classes(name, classes);

		if (classes)
		{
			gpa = Calculate_GPA(grade, number, classes, sum);
		}
		
		Print_Results(name, gpa);
		}
}

int Get_Name_and_Num_Classes(string& name, int classes)
{
	cout << "Enter the student's last name: ";
	cin >> name;
	if(name == "xxx") {return 0;}

	cout << endl << "How many classes taken: ";
	cin >> classes;

	return (classes);
}

double Calculate_GPA(char& grade, int number, int classes, double sum)
{
	string name;
	int count = 1;
	double gpa = 0.00;

	while (count <= classes)
{
    number = Convert_Let_to_Num(number);
    sum = sum + number;
    count = count + 1;
}
gpa = sum / classes;

cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);

return gpa;
}

void Get_Letter_Grade(char& grade, int classes)
{
	string name;
	int count = 1;
	
	while (count <= classes)
	{
	cout << endl << "Enter letter grade " << count << ": ";
	cin >> grade;
	count ++;
	}
	
}
int Convert_Let_to_Num(int number)
{
	char grade = ' ';
	Get_Letter_Grade(grade, classes);
	
	if ((grade == 'a') || (grade == 'A'))
	{
		number = 4;
	}
	else if ((grade == 'b') || (grade == 'B'))
	{
		number = 3;
	}
	else if ((grade == 'c') || (grade == 'C'))
	{
		number = 2;
	}
	else if ((grade == 'd') || (grade == 'D'))
	{
		number = 1;
	}
	else if ((grade == 'f') || (grade == 'F'))
	{
		number = 0;
	}
 else
  number = 0;

	return (number);
}

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

ok nevermind it did go through but loops back to enter grade 1

any idea why it keeps looping back to enter the first grade...i think i just about got it......

//Name: Bryan Kruep
//Class: CS 140-001
//Assignment: Project 4
//Date: 03/27/08
#include <iostream>
#include <string>
using namespace std;
int Get_Name_and_Num_Classes(string& name, int classes);
double Calculate_GPA(char& grade, int number, int classes, double sum);
void Get_Letter_Grade(char& grade, int classes);
int Convert_Let_to_Num(int number, int classes);
void Print_Results(string name, double gpa);

int main()
{
	string name;
	int sum = 0, number = 0;
	int classes = ' ';
	char grade = ' ';
	double gpa = 0.0;

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

	while (name != "xxx")
	{
		classes = Get_Name_and_Num_Classes(name, classes);

		if (classes)
		{
			gpa = Calculate_GPA(grade, number, classes, sum);
		}
		
		Print_Results(name, gpa);
		}
}

int Get_Name_and_Num_Classes(string& name, int classes)
{
	cout << "Enter the student's last name: ";
	cin >> name;
	if(name == "xxx") {return 0;}

	cout << endl << "How many classes taken: ";
	cin >> classes;

	return (classes);
}

double Calculate_GPA(char& grade, int number, int classes, double sum)
{
	string name;
	int count = 1;
	double gpa = 0.00;

	while (count <= classes)
{
    number = Convert_Let_to_Num(number, classes);
    sum = sum + number;
    count = count + 1;
}
gpa = sum / classes;

cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);

return gpa;
}

void Get_Letter_Grade(char& grade, int classes)
{
	string name;
	int count = 1;
	
	while (count <= classes)
	{
	cout << endl << "Enter letter grade " << count << ": ";
	cin >> grade;
	count ++;
	}
	
}
int Convert_Let_to_Num(int number, int classes)
{
	char grade = ' ';
	Get_Letter_Grade(grade, classes);
	
	if ((grade == 'a') || (grade == 'A'))
	{
		number = 4;
	}
	else if ((grade == 'b') || (grade == 'B'))
	{
		number = 3;
	}
	else if ((grade == 'c') || (grade == 'C'))
	{
		number = 2;
	}
	else if ((grade == 'd') || (grade == 'D'))
	{
		number = 1;
	}
	else if ((grade == 'f') || (grade == 'F'))
	{
		number = 0;
	}
 else
  number = 0;

	return (number);
}

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

so here is what is happening i kind of figured out what it is doing....the number of classes I type in is the number of times it loops through so meaning if i type in 3 classes it will loop 3 times...the other issue is the final gpa is only the last number I type in....Kinda confused on how this could happen

I have figured out that it only configures the final loop of grades so it must come out somehow

any idea why it keeps looping back to enter the first grade...i think i just about got it......

void Get_Letter_Grade(char& grade, int classes)
{
	string name;
	int count = 1;
	
	while (count <= classes)//<-Here's your culprit.
	{
	cout << endl << "Enter letter grade " << count << ": ";
	cin >> grade;
	count ++;
	}
	
}

Get_Letter_Grade is looping infinitely - its the only function capable of outputting the prompt.

last question i promise...either that or i let my teacher know what I think about this program assignment...ok not really but I changed the void print to exit out if the xxx is typed but now the count stays at 1...I had it working a second ago and must have changed something i know it has something to do with a count ++ but not sure where i moved it

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

int main()
{
	string name;
	int sum = 0, number = 0;
	int classes = ' ';
	char grade = ' ';
	double gpa = 0.0;

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

	while (name != "xxx")
	{
		classes = Get_Name_and_Num_Classes(name, classes);

		if (classes)
		{
			gpa = Calculate_GPA(grade, number, classes, sum);
		}
		
		Print_Results(name, gpa);
		}
}

int Get_Name_and_Num_Classes(string& name, int classes)
{
	cout << "Enter the student's last name: ";
	cin >> name;
	if(name == "xxx") {return 0;}

	cout << endl << "How many classes taken: ";
	cin >> classes;

	return (classes);
}

double Calculate_GPA(char& grade, int number, int classes, double sum)
{
	string name;
	int count = 1;
	double gpa = 0.00;

	while (count <= classes)
{
    number = Convert_Let_to_Num(number, classes);
    sum = sum + number;
    count = count + 1;
}
	
gpa = sum / classes;
	
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);

return gpa;
}

void Get_Letter_Grade(char& grade, int classes)
{
	string name;
	int count = 1;
	
	{
	cout << endl << "Enter letter grade " << count << ": ";
	cin >> grade;
	
	}
	
}
int Convert_Let_to_Num(int number, int classes)
{
	char grade = ' ';
	Get_Letter_Grade(grade, classes);
	
	if ((grade == 'a') || (grade == 'A'))
	{
		number = 4;
	}
	else if ((grade == 'b') || (grade == 'B'))
	{
		number = 3;
	}
	else if ((grade == 'c') || (grade == 'C'))
	{
		number = 2;
	}
	else if ((grade == 'd') || (grade == 'D'))
	{
		number = 1;
	}
	else if ((grade == 'f') || (grade == 'F'))
	{
		number = 0;
	}
 else
  number = 0;

	return (number);
}

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

could it be something in here with the while loop.....

double Calculate_GPA(char& grade, int number, int classes, double sum)
{
	string name;
	int count = 1;
	double gpa = 0.00;

	while (count <= classes)
{
    number = Convert_Let_to_Num(number, classes);
	sum = sum + number;
    count = count + 1;
	
}

Try passing Calculate_GPA::count by value to Convert_Let_to_Num, so that Convert_Let_to_Num can pass it by reference to Get_Letter_Grade. Then use a line in Get_Letter_Grade to increment count. And leave the while loop out of Get_Letter_Grade.

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.