I know it has to do something with my main and around the "how many classes" but my program runs without any errors or warnings but blows up so I was wanting to know if someone could take a look at it.....

I know I havent worked on the gpa so that can be ignored for now....

my code:

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

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

	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");

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

		}while (count <= classes)
		
		{
		cout << endl << endl << "Enter letter grade " << count << ": ";
		Get_Letter_Grade(grade);
		count ++;
		}
		//gpa = Calculate_GPA(grade, count);
		number = Convert_Let_to_Num(number);
		Print_Results(name, gpa);
	}while (name != "xxx");

	return 0;
}

int Get_Name_and_Num_Classes(string variable)
{
	int x = 0;
	cin >> x;
	return x;

}

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

//calculate gpa here

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

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

output should be:

Programmed by <your name>

Type xxx for the name to exit

Enter the student's last name: Mickey
How many classes taken: 3

Enter letter grade 1: a
Enter letter grade 2: B
Enter letter grade 3: b

Student Mickey has a semester GPA of 3.33

Enter the student's last name: Goofy
How many classes taken: 5

Enter letter grade 1: c
Enter letter grade 2: C
Enter letter grade 3: d
Enter letter grade 4: b
Enter letter grade 5: a

Student Goofy has a semester GPA of 2.40

Enter the student's last name: Donald
How many classes taken: 2

Enter letter grade 1: c
Enter letter grade 2: B


Student Donald has a semester GPA of 2.50

Enter the student's last name: Minnie
How many classes taken: 4

Enter letter grade 1: A
Enter letter grade 2: A
Enter letter grade 3: B
Enter letter grade 4: A

Student Mickey has a semester GPA of 3.75

Enter the student's last name: xxx

line 35: you need to pass variable grade by reference to that Get_Letter_Grade() can change its value. Then in main() you need to save all the graded in an array so that the GPA can be calculated.

line 39: the value of number is never set to anything so all it is passing to Convert_Let_to_Num() is the3 value 0 (line 14)

not allowed to use arrays

Ok, so another way to do it is to sum up all the grades and divide the the number of grades. Such as:

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

still blowing up.....

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

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

	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");

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

		}while (count <= classes)
		
		{
		cout << endl << endl << "Enter letter grade " << count << ": ";
		Get_Letter_Grade(grade);
		number = Convert_Let_to_Num(number);
		sum = sum + number;
		count = count + 1;
		count ++;
		}
		//gpa = Calculate_GPA(grade, count);
		number = Convert_Let_to_Num(number);
		Print_Results(name, gpa);
	}while (name != "xxx");

	return 0;
}

int Get_Name_and_Num_Classes(string variable)
{
	int x = 0;
	cin >> x;
	return x;

}

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

//calculate gpa here

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

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

I tried putting in by reference and this is what I got.....

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

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

	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");

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

		}while (count <= classes)
		
		{
		cout << endl << endl << "Enter letter grade " << count << ": ";
		Get_Letter_Grade(grade);
		number = Convert_Let_to_Num(number);
		sum = sum + number;
		count = count + 1;
		count ++;
		}
		//gpa = Calculate_GPA(grade, count);
		number = Convert_Let_to_Num(number);
		Print_Results(name, gpa);
	}while (name != "xxx");

	return 0;
}

int Get_Name_and_Num_Classes(string variable)
{
	int x = 0;
	cin >> x;
	return x;

}

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

//calculate gpa here

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

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

line 49: Get_Name_and_Num_Classes() -- that seems to be a misnamed function. Your program expects it to return a string from line 24 but it actually returns an integer. You could hack it to return both a string and an integer but it would be a lot better to use two different functions -- GetNumClasses() and GetName(). If you do that then there will be no confusion about what it should return. And neither function needs a parameter.

line 36 of your most recent attempt is incorrect. Pass grade as the parameter, not number.

we are not allowed to do that either....here let me give u the instructions for this program so you might have a better understanding.


Write a program to compute a student’s GPA for one semester. It should ask the user for the student’s last name, and how many classes were taken during the semester. It will then ask the user to type in the letter grade for each class and print the GPA to the screen.

The program should continue doing this until the user types an xxx for the last name.
Program Requirements
• To make the program easier, assume all classes are 3 credits.
• There should be two digits of precision
• You should have the following functions:
• Get_Name_and_Num_Classes - This function asks the user to type in their name and the number of classes taken
• Calculate_GPA - This function computes GPA. It does this by looping. It call Get_Letter_Grade to allow the user to enter a valid letter grade and then it calls Convert_Let_to_Num. It uses this information to compute the GPA. It returns the GPA. (you should be able to determine the formal parameters)
• Get_Letter_Grade – This function is a void function. It asks the user to type in a letter grade, and then makes sure that the letter grade is valid. It must be an A, B, C, D, or F. You should be able to determine the formal parameters.
• 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.
• Print_Results - This prints all results to the screen. It should not return a value.

here is my code:

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

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

	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");

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

		}while (count <= classes)
		
		{
		cout << endl << endl << "Enter letter grade " << count << ": ";
		Get_Letter_Grade(grade);
		number = Convert_Let_to_Num(grade);
		sum = sum + number;
		count = count + 1;
		count ++;
		}
		//gpa = Calculate_GPA(grade, count);
		number = Convert_Let_to_Num(number);
		Print_Results(name, gpa);
	}while (name != "xxx");

	return 0;
}

int Get_Name_and_Num_Classes(string variable)
{
	int x = 0;
	cin >> x;
	return x;

}

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

//calculate gpa here

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

void Print_Results(string name, double gpa)
{
	cout << "Student " << name << " has a semester GPA of " << gpa;
}
int Convert_Let_to_Num(int number)
{
	char grade = 0;
	if ((grade == 'a') || (grade == 'A'))
	{
		number = 4;

Q1: What answer do you expect given that you set grade to 0, then proceed to test it against various letters.

Q2: If all you do is assign 1 to 4 to number, what do you think happens to the value you pass as a parameter?

line 5: the parameter prompt is misnamed -- should be name and passed by reference int Get_Name_and_Num_Classes(string& name); then change line 24 to use the above function prototype and change the function beginning at line 45 to do as instructed storing the name the the user typed into the parameter name and returning the number of classes. The function you wrote does not do that.

you can delete lines 23 and 24 because that info belongs in function Get_Name_and_Num_Classes().

I think the do loop lines 21-44 can be abbreviated

std::string name;
int numClasses = 0;
int sum = 0;
do 
{
    numClasses = Get_Name_and_Num_Classes(name);
    if( name != "xxx" )
    {
         GPA = Calculate_GPA(numClasses);
    }
} while( name != "xxx");

should I pass by reference the int as well...I think I did most of what you said just still not compiling how I want it to

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

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

	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);

		if (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 << ": ";
		Get_Letter_Grade(grade);
		number = Convert_Let_to_Num(grade);
		sum = sum + number;
		count = count + 1;
		count ++;
		}
		//gpa = Calculate_GPA(grade, count);
		number = Convert_Let_to_Num(number);
		Print_Results(name, gpa);
	}while (name != "xxx");

	return 0;
}

int Get_Name_and_Num_Classes(string& name, int classes)
{
	int x = 0;
	cin >> x;
	return x;

}

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

//calculate gpa here

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

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

Read post 9.

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

You'll never execute any of the code inside any of these if statements under any circumstances.

lines 21-44 -- read post #10. you put too much code in main(), most of it belongs in other functions.

significant changes made....does it look like I have everything done before I calculate gpa

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

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

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

	do
	{
		
		name = Get_Name_and_Num_Classes(name, classes);

		if (name != "xxx")
		{
			classes = Get_Name_and_Num_Classes(name, classes);
			Get_Letter_Grade(grade);
			number = Convert_Let_to_Num(grade);
			gpa = Calculate_GPA(grade, number);
			Print_Results(name, gpa);
		}
		
	}while (name != "xxx");

	return 0;
}

int Get_Name_and_Num_Classes(string& name, int classes)
{
	cout << "Enter the student's last name: ";
	cin >> name;

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

	return (name, classes);
}

void Get_Letter_Grade(char& grade)
{
	int number = 0, count = 1, sum = 0;
	cout << endl << endl << "Enter letter grade " << count << ": ";
	cin >> grade;
	sum = sum + number;
	count++;
}

//calculate gpa here

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

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

It is still wrong. Verify that you did at lines 28 - 31 with program requirements you posted earlier. You have to read the requirements very very carefully in order to get all the function calls in the correct order.

• Calculate_GPA - This function computes GPA. It does this by looping. It call Get_Letter_Grade to allow the user to enter a valid letter grade and then it calls Convert_Let_to_Num. It uses this information to compute the GPA. It returns the GPA. (you should be able to determine the formal parameters)

line 48: it is not possible to return two variables like that. When the string name is passed by reference you don't have to return it because that's what pass-by-reference means. So all line 48 needs to do is return the integer.

lint 51: Get_Letter_Grade(). That function is doing too much work. Re-read the program requirements you posted and make the function do exactly what the requirements says it should do and nothing more.

Same problem as before in this function. You've just changed it from initializing grade to 0 to initializing it to a blank space. Again, you'll never reach any of the code inside the if statements. You will simply return the number you passed to the function.

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

Look at your function call to this function on line 30 in the original code you posted. You are passing this function the variable grade, which you've defined as a character in line 15 of your original code. You are passing a character to the function above, which is expecting an integer as a parameter:

int Convert_Let_to_Num(int number)

You need to change this function so that it takes a character as a parameter,a s the name implies: Convert_Let_to_Num. In order to convert a letter to a number, the function must accept a letter, which is a character, as a parameter.

hope this looks somewhat better w\the exception of moving the functions around

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

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

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

    do
    {

        name = Get_Name_and_Num_Classes(name, classes);

        if (name != "xxx")
        {
            classes = Get_Name_and_Num_Classes(name, classes);
            number = Get_Letter_Grade(grade);
            number = Convert_Let_to_Num(grade);
            sum = sum + number;
            count = count + 1;
            gpa = Calculate_GPA(grade, number);
            Print_Results(name, gpa);
        }

    }while (name != "xxx");

    return 0;
}

int Get_Name_and_Num_Classes(string& name, int classes)
{
    cout << "Enter the student's last name: ";
    cin >> name;

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

    return (classes);
}

void Get_Letter_Grade(char& grade)
{
    int number = 0;
    cout << endl << endl << "Enter letter grade " << count << ": ";
    cin >> grade;

}

//calculate gpa here

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

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

[/code}[code=c++]


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


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


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


do
{


name = Get_Name_and_Num_Classes(name, classes);


if (name != "xxx")
{
classes = Get_Name_and_Num_Classes(name, classes);
number = Get_Letter_Grade(grade);
number = Convert_Let_to_Num(grade);
sum = sum + number;
count = count + 1;
gpa = Calculate_GPA(grade, number);
Print_Results(name, gpa);
}


}while (name != "xxx");


return 0;
}


int Get_Name_and_Num_Classes(string& name, int classes)
{
cout << "Enter the student's last name: ";
cin >> name;


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


return (classes);
}


void Get_Letter_Grade(char& grade)
{
int number = 0;
cout << endl << endl << "Enter letter grade " << count << ": ";
cin >> grade;


}


//calculate gpa here


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


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


[/code}

sorry....

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

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

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

	do
	{
		
		name = Get_Name_and_Num_Classes(name, classes);

		if (name != "xxx")
		{
			classes = Get_Name_and_Num_Classes(name, classes);
			number = Get_Letter_Grade(grade);
			number = Convert_Let_to_Num(grade);
			sum = sum + number;
			count = count + 1;
			gpa = Calculate_GPA(grade, number);
			Print_Results(name, gpa);
		}
		
	}while (name != "xxx");

	return 0;
}

int Get_Name_and_Num_Classes(string& name, int classes)
{
	cout << "Enter the student's last name: ";
	cin >> name;

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

	return (classes);
}

void Get_Letter_Grade(char& grade)
{
	int number = 0;
	cout << endl << endl << "Enter letter grade " << count << ": ";
	cin >> grade;

}

//calculate gpa here

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

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

sorry....

Next time just hit the Edit This Post button and correct the code tags or whatever else you want to change. No need to repost if you catch mistakes within about 10 minutes.

is that starting to look a lil better ?

No. You are still not reading program requirements very well. Re-read sentence by sentence. Code one sentence then when that is done code the next sentence. I've already mentioned lines 28-33 are wrong.

• Calculate_GPA - This function computes GPA. It does this by looping. It call Get_Letter_Grade to allow the user to enter a valid letter grade and then it calls Convert_Let_to_Num. It uses this information to compute the GPA. It returns the GPA. (you should be able to determine the formal parameters)

Where in the above does it tell you to place the call to Convert_Let_To_Num() in main() at line 30? Answer: it doesn't. Put the damed function call in Calculate_GPA() where the requirements tell you to put it.

One of the qualities of a programmer is the ability to follow instructions by the letter. If you can't do that then just quit and go get a beer (if you are old enough).

Have no intentions of being a programmer(required for my major)...I suck at it. I am the first to admit that but besides Ancient Dragon can anyone take a look at this and tell me if this is starting to look better(only cuz he has helped me alot and dont wanna keep bothering him)

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

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

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

	do
	{
		
		name = Get_Name_and_Num_Classes(name, classes);

		if (name != "xxx")
		{
			gpa = Calculate_GPA(grade, number);
		}
		Print_Results(name, gpa);

	}while (name != "xxx");

	classes = Get_Name_and_Num_Classes(name, classes);


	return 0;
}

int Get_Name_and_Num_Classes(string& name, int classes)
{
	cout << "Enter the student's last name: ";
	cin >> name;

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

	return (classes);
}

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

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

return gpa;
}

void Get_Letter_Grade(char& grade)
{
	int count = 0;
	cout << endl << endl << "Enter letter grade " << count << ": ";
	cin >> grade;

}



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

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

First:
Your Calculate_GPA needs to accept the classes from your main function. But since it doesn't actually need to operate on classes , you can get by with making it a constant in the arguments list. You can then make the changes in the definition (it has to match the prototype). Since you'll be passing classes to the function, you'll need to edit line 53 accordingly - if you don't, you're compiler should complain.

Second:
On line 24, your Get_A_Name_and_Num_Classes function returns an integer. So anything you assign it to should be an integer not a string (I believe Ancient Dragon warned you about this already). Just changing the variable should correct that issue.

Third:
How it's written now, you're do..while doesn't actually care what name equals. If you're not required to use the do..while, you can get the same end result using a regular while loop.
Use the value of name to get into the loop (hint: while( name != "xxx") ) and use the value of classes to get out (hint: if(classes == /*some unique value*/) . Once you're in the while loop (in main()) you can call the same functions you have in there now. The difference is that your G_N_a_N_C function will need to return a UNIQUE value that you can test against to cause the break; . It wouldn't help you learn if I just wrote the code, but trust me - it's not as complicated as it seems.

These are just the first three big things I noticed. There a few other little bugs - but until lines 21-34 are working, it's pointless to track down the others.

BTW: We all suck when start out.

We are not allowed to use breaks. I have made some sifinificant changes to my program I believe. As you can see right now I have the enter grade to add a new grade but it is not stopping....I know it must be something in a loop that is wrong or a wrong variable name but can't figure it out.

Also I changed some things around with exiting with the string but it is still not working...is there anyway to do this without using the string to exit because this issue has just been giving me all kinds of problems and frustrations since starting the program....

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

int main()
{
	string name;
	int classes = ' ', sum = 0, number = 0;
	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);
		}
		
		Print_Results(name, gpa);
		}
	return 0;
}

int Get_Name_and_Num_Classes(string& name, int classes)
{
	cout << "Enter the student's last name: ";
	cin >> name;

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

	return (classes);
}

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

	while (count <= classes)
{
    Get_Letter_Grade(grade);
    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 count = 1, classes = ' ';
	while (count <= classes)
	{
	cout << endl << "Enter letter grade " << count << ": ";
	cin >> grade;
	count ++;
	}

}
int Convert_Let_to_Num(int number)
{
	char grade = ' ';
	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;
}

I even compared an older program to this one in the count and nothing seems different.....

#include <iostream>
#include <string>
using namespace std;
const double INCENTIVE = 1.25;

int main ()
{
int gamesInSeason, pointsScored, pointsTotal = 0;
double averagePoints, incentiveTotal;
int count = 1;

	cout << "Programmed By: Jim Johnson\n" <<endl;

	cout << "Number of games in season: ";
	cin >> gamesInSeason;


	while (count <= gamesInSeason)
	{
		
		cout << "Points scored in game " << count << ": ";
		cin >> pointsScored;
		count ++;
		pointsTotal = pointsTotal + pointsScored;
		
	
	}

averagePoints = pointsTotal / gamesInSeason;
incentiveTotal = INCENTIVE * pointsTotal;
	
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout << endl << "Player scored a total of " << pointsTotal << " points this season. ";
cout << endl << "Average points per game was " << averagePoints;
cout << endl << "Incentive pay earned was " << incentiveTotal;
cout << endl <<endl;


	
		return 0;
	}

Ok I think I did what you told me to do which is to declare the classes as constants but still came back with some errors.....

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

int main()
{
	string name;
	int sum = 0, number = 0;
	const 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);
		}
		
		Print_Results(name, gpa);
		}


}

int Get_Name_and_Num_Classes(string& name, int classes)
{
	cout << "Enter the student's last name: ";
	cin >> name;

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

	return (classes);
}

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

	while (count <= classes)
{
    Get_Letter_Grade(grade);
    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 count = 1;
	const classes;
	while (count <= classes)
	{
	cout << endl << "Enter letter grade " << count << ": ";
	cin >> grade;
	count ++;
	}

}
int Convert_Let_to_Num(int number)
{
	char grade = ' ';
	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;
}

line 5: where is classes defined?

I have it defined as an integer because when i try a const like the previous person said...I get a ton of errors...When I do it this way I am able to get it to enter the grade but just keeps looping from within the grade......

#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);
void Get_Letter_Grade(char& grade);
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);
		}
		
		Print_Results(name, gpa);
		}


}

int Get_Name_and_Num_Classes(string& name, int classes)
{
	cout << "Enter the student's last name: ";
	cin >> name;

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

	return (classes);
}

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

	while (count <= classes)
{
    Get_Letter_Grade(grade);
    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 count = 1;
	int classes = ' ';
	while (count <= classes)
	{
	cout << endl << "Enter letter grade " << count << ": ";
	cin >> grade;
	count ++;
	}

}
int Convert_Let_to_Num(int number)
{
	char grade = ' ';
	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;
}

To get out of the loop, you can still use a sentinel value in a round-about way.

while (name != "xxx")
	{

		classes = Get_Name_and_Num_Classes(name, classes);

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

		Print_Results(name, gpa);
	}

This way, you'll only calculate a GPA if there were any classes. So to prevent "xxx" from having any classes, you'll have to modify how the Get_Name_and_Num_Classes works.

int Get_Name_and_Num_Classes(string& name, int classes)
{
	cout << "Enter the student's last name: ";
	cin >> name;
	if(name == "xxx") {return 0;}//<-Make main::classes==false
	cout << endl << "How many classes taken: ";
	cin >> classes;
	return (classes);
}

This gets you out of the loop if the user enters "xxx" for a name - with no break; (you're teacher has a sick sense of humor.j/k).

Also, watch out on Line 28 -- you're assigning ' ' to classes, not checking its equivalence.

You'll also need to pass 'classes' to every function that needs to know how many classes where taken. So look through your code - you can see that Calculate_GPA is affected.

As far as Calculate_GPA goes, you don't need Get_Letter_Grade inside of a loop, since it has a loop that governs it. You can use Get_Letter_Grade's loop to also call Convert_Let_to_Num.

This way, the only thing Calculate_GPA does is call Get_Letter_Grade, calculate the GPA and set the IO formatting.

To allow this though, you'll have to pass more variables between functions.

commented: Good advice given in this thread! +2

>>I have it defined as an integer because when i try a const like the previous person said
I didn't read what he said but I suspect he meant that classes should be declared as const int only where it appears in the parameter list of a function. All other places do not use const keyword. And you can't use const all by itself because it requires a data type, such as int or char*. All const means is that its value can not be changed.

line 71: you need to pass the value of classes as a parameter to that function. On line 4 you have destroyed the value that was originally entered at line 24 -- don't do that.

[edit]Also what ^^^he said :) [/edit]

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.