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