My code, in 'full' (only 89 lines, lol) is here. My input file is here and (for kicks and giggles) my outuput file when I comment out the else... if statements and have simply fout is here. (Remove the .txt on the last two...)

I'm having a problem with my if else statement. When I comment out the else if stuff, it works.

(Choice is an int)

if (choice == 1)	
{
	fout << fixed << showpoint << setprecision(2);
	fout << "The average female gpa is " << AverageFemaleGPA << endl << endl;
	fout << "The average male gpa is " << AverageMaleGPA << endl << endl;
	fout << "The overall gpa is " << AverageGPA << endl;
}
else if (choice == 2)
{
	cout << fixed << showpoint << setprecision(2);
	cout << "The average female gpa is " << AverageFemaleGPA << endl << endl;
	cout << "The average male gpa is " << AverageMaleGPA << endl << endl;
	cout << "The overall gpa is " << AverageGPA << endl;
}

Is is supposed to be something like <= and not ==? Choice does either equal 1 or 2, and if it is 3 it skips all of them to the end. But the above code skips over them, even though for it to get out of the while loop it HAD to work.

Does it have something with the preceding do while loop?

do
{ 
	cout << "What would you like to do?" << endl << endl;
	cout << "1. Output the gpa information to an output file." << endl << endl;
	cout << "2. Display the gpa information on the screen." << endl << endl;
	cout << "Exit the program." << endl << endl;
	cout << "Enter your selection:";
	cin >> choice;
}
while (choice!=1 && choice!=2 && choice!=3);

I'm sure I made a stupid mistake... indeed, for a while It did not work: I was giving choice the value of 2 or 1 each time! ( else if (choice = 2))

Thanks for the help! I have this due tomorrow, so no matter what I'll be getting it done. I hate getting all of the work (I know easy for some of you, but I'm a beginner) and then something simple stupid not letting it work. And I KNOW a switch would work, but the prof does not want one!

I name my files funny, by the way. The name of the project? Poppus_of_sorrowz. I believe I have more fun making the name than the code itself... although making kickbutt code, above and beyond what the professor wants, is fun. But I'm going for KISS (Keep it simple, stupid) for now, as I don't have time for very pretty code, with extra stuff (as much as I would like to do that! School can be a pain, so much to study for!

um. yeas.

So I DID NOTHING to the code, except let a friend look at it and uncomment the hated stupid section... and it worked. Stupid.

Thanks for looking!

Don't ever ever try to get cute with your code. Professors really seriously hate that.

I think you have not included iostream or have not written using namespace std;

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.