If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Simple GradeSystem

Hello,
New here and hope to stay. Anyways...

I have started back with C++ and wanted to see how much I remembered. So please tell me what I am doing wrong. I am on linux at the moment and could not remeber if you used <iostream> with windows or linux.

Also need explanations on what do, I believe one of the main problems with my code is I need to keep the variables in ( ).

int main(){
//startup variables that we will use
char studentName[255];
int studentAverage;
int gradeNumber; // amount of student Averages
int totalAmount; //will hold all averages
int submitAmount; //amount submited during for loop session
char letterGrade; // will store the lettergrade before it is written to grades.txt
int theTime; // will hold the current time
bool canWe; // asks if we can continue

// find out who we will be grading
cout << "Hello user!" << endl;
cout << "This program lets you average the grade of your student and write there grade in a text file." << endl;
cout << "Who will be writting a grade for today?" << endl << "Name: ";
cin >> studentName >> endl;
cout << "Ok, we will be grading " << studentName << "today!" << endl;

The first test is true, so letterGrade gets assigned A.
The second test is also true, so letterGrade no gets assigned a B, etc.

letterGrade is defined in two places, one as an int and one as a char. A, B, C, etc. aren't defined anywhere. If you mean to use them as chars, wrap them in single quotes.

May I add that none of those are actually assignements? They are all just equality operators, and hence, do nothing. You want "=" not "=="

...

The funny part is that people usually mess up the other way:

Code:

if (i = 5) //always true
{
...
}

Is your question related to IO?
Read this C++ FAQ LITE article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.

What are you trying to do with gradeNumber?
You have an unconditional return in the loop.
You can only return one value.
Your function calls after the loop won't be executed because of the return in the for loop.

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.