Thread: C++ help
View Single Post
Old January 2nd, 2006, 02:18 PM  
Kiros
Retired Administrator
 
Kiros's Forum Picture
 
Name: Ben
Join Date: May 22, 2004
Location: Albany, LA - USA
Age: 27
Gender: Male
Blog Entries: 17
Default Re: C++ help

Code:
cout << "Phase 3\n"
	 << "Phase 3 consists of relaying you teh information\n\n\n\n" << endl;

cout << "Would you like to see the class average? Y/N\n" << endl;
//Did you forget the cin >> phase3; Or did you want to do the following in stead?

if (phase3 = cin.get()) { //Did you mean phase3 == cin.get() maybe?
	                       //An IF statement really isn't something to set values with :?
	switch (phase3) {

	case 'Y': //Try to use "" for quotes, as it binds tighter than ''
	case 'y':
		phase3++;
		break;

	case 'N':
	case 'n':
		break;

		if (phase3 == 0)
			break;
	}
}

cout << fixed << setprecision (2) << phase1 << "\n\n" << endl;

cout << "Would you like to see the letter grades? Y/N" << endl;
phase3 = 0;

while (phase3 == 0) { //You should really use do..while instead of while and a continue :?
	cin >> phase3;
	switch (phase3) {

	case 'Y':
	case 'y':
		phase3++;
		break;

	case 'N':
	case 'n':
		break;

		if (phase3 == 0)
			continue;
	}
}

cout << "\nA: " << aGrade
	 << "\nB: " << bGrade
	 << "\nC: " << cGrade
	 << "\nD: " << dGrade
	 << "\nF: " << fGrade
	 << endl;
Ok, I've marked it up for you to check - read all the comments in it. And I am assuming you made an enumeration for your aGrade - fGrade, right?

Kiros || Ben

Happiness is not about being perfect.
It is about seeing beyond the imperfections.
Kiros is offline   Reply With Quote