Thread: C++ help
View Single Post
Old January 2nd, 2006, 02:40 PM  
Skhorpion
Awesome Poster
 
Join Date: October 17, 2005
Location: Middle Tennessee
Age: 25
Gender: Male
Default

still didnt work.... here the entire thing as something i put earlier might be messing it up

Code:
#include <iostream>
using namespace std;
#include <iomanip>
#include <cstdlib>

int main()
{


int total = 0;
int gradeCounter = 0;
int grade;
int grader = 0;
int aGrade = 0;
int bGrade = 0;
int cGrade = 0;
int dGrade = 0;
int fGrade = 0;
int phase3;

double phase1;

cout << "Ultimate Grade Report\n"
	 << "Enter grade to begin phase 1\n"
     << "Phase 1 consists of getting the class average\n"
	 
	 << "CTRL + Z to end\n";
cin >> grade;

while (grade != -1) {
	total = total + grade;
	gradeCounter++;
	cout << "Enter grade\n";
	cin >> grade;
}

if (gradeCounter != 0) {

	phase1 = static_cast< double > (total) / gradeCounter;
}

else {
	cout << "No Grades" << endl;
}
system ("cls");
cout << "Phase 2\n"
	 << "Phase 2 consists of finding what grade letter the students got\n" << endl;

cout << "Enter student letter grade\n";

while ( (grader = cin.get() ) != EOF) {
	
	switch (grader){

	
	case 'A':
	case 'a':
		aGrade++;
		break;

	case 'B':
	case 'b':
		bGrade++;
		break;

	case 'C':
	case 'c':
		cGrade++;
		break;

	case 'D':
	case 'd':
		dGrade++;
		break;

	case 'F':
	case 'f':
		fGrade++;
		break;

	case '\n':
	case '\t':
	case ' ':
		break;

	default:
		cout << "Incorrect grade, Please re-enter.";
		break;
	}
}
system ("cls");
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;

cin.get();

return 0;
}

All is fair in love and war.
Skhorpion is offline   Reply With Quote