This is for homework, so please don't give me code, just suggestions in the right direction.
I am writing a program that will ask the user for a final grade, and then from that, determine if the user enters an expression or a number. If the user enters and expression then I need to compute the solution.
I cannot use anything but if statements, and that is as far as we have gone in this class thus far.
So here is the code I have written so far:
code removed
When I compiled this last I did not get any errors but it displays the output weird.
I just want to preface this with, I have some specific questions but if I am not even headed down the right road, don't want to waste time writing them. If I am, then I will post the other questions. I apologize if this is somewhat difficult to understand, but am going pretty cross-eyed.
if (grade == '+' || '-' || '*' || '/' || '%'){ //if user does not enter an int, but enters an expression
This will not work as you expect it to. Try to run this program and enter 42 for grade. EDIT: Actually, enter ANYTHING. What you wrote there is always true.
OK, so moving forward from here, I actually flow charted this out. Program asks for a grade, from there it has to determine if the grade entered is an integer or an expression. How do I accomplish that? Do I ask the program to look for an operator? In other words, here is my dilemma.
If the program can in fact look for an operator, how do I then have the program perform that operation with the numbers the user entered?
If I cannot have the program determine determine an expression based on operator, what would you suggest?