I don't understand what I am doing wrong here. I am trying to quickly write this program so that I can use it to test a flowchart diagram that I made earlier. When the output comes up on the console "Enter a course name" and I put any input in and hit Enter, the program skips the other output and input sections that I have coded in.

#include <iostream>
#include <string>
using namespace std;

int main()
{
	double totalGradePoints = 0.0;
	double totalUnitHours = 0.0;
	double tripValue = 0.0;
	char courseName;
	double unitHours = 0;
	char letterGrade;
	double gradePoints = 0;
	double gradePointAverage;

	while(tripValue < 5)
	{
		cout << "Enter A Course Name." << endl;
		cin >> courseName;
		cout << "Enter Unit Hours for the Course." << endl;
		cin >> unitHours;
		cout << "Enter a Letter Grade. (Please enter in UpperCase Letters.)" << endl;
		cin >> letterGrade;
		switch (letterGrade)
		{
			case 'A':
				gradePoints = unitHours * 4.0;
				break;
			case 'B':
				gradePoints = unitHours * 3.0;
				break;
			case 'C':
				gradePoints = unitHours * 2.0;
				break;
			case 'D':
				gradePoints = unitHours * 1.0;
				break;
			case 'F':
				gradePoints = unitHours * 0.0;
				break;
			default:
				cout << "Your Letter Grade was not valid.  Please Restart the program." << endl;
		}
		totalGradePoints = totalGradePoints + gradePoints;
		totalUnitHours = totalUnitHours + unitHours;
		cout << "Course Name: " << courseName << endl;
		cout << "Letter Grade: " << letterGrade << endl;
		cout << "Unit Hours: " << unitHours << endl;
		cout << "Grade Points Earned for This Course: " << gradePoints << endl;
		tripValue++;
	}
	gradePointAverage = totalGradePoints / totalUnitHours;
	cout << "Total Grade Points: " << totalGradePoints << endl;
	cout << "Total Credit Hours Attempted: " << totalUnitHours << endl;
	cout << "Overall GPA: " << gradePointAverage << endl;

	return 0;
}

Also I just wanted to add... Even when I comment out the while (tripValue < 5) and the brackets it still won't let me enter the letter grade or the unit hours.

Hello ThrasherK,
I hope coursename is a string. In the line 10 you have declared coursename as character variable. Declare it as a pointer or as a character array.

Hello ThrasherK,
I hope coursename is a string. In the line 10 you have declared coursename as character variable. Declare it as a pointer or as a character array.

Hello Arbus,
Thank you. I don't know what I was thinking. I guess I was just in a hurry. I appreciate 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.