Hi...
I am doing this simple Java program which displays a particular grade (A, B, C...) according to the mark entered.
However I cannot arrange it in such a way that it displays "Invalid" if the user eners a grade > 100... take a look...
after compiled it keeps telling me that this is not a statement:
can't figure why ..
The program however runs, and if the user enters "101" for exmple, it keeps obeying the second 'else if'....
Any ideas pls....?
thanks
I am doing this simple Java program which displays a particular grade (A, B, C...) according to the mark entered.
However I cannot arrange it in such a way that it displays "Invalid" if the user eners a grade > 100... take a look...
Code:
System.out.print ("Enter mark: ");
int mark = Keyboard.readInt();
char grade =' ';
if (mark > 100) (System.out.println ("Invalid Entry"));
else if (mark >=80 && mark <= 100) grade = 'A';
else if (mark >= 60) grade = 'B';
else if (mark >= 55) grade = 'C';
else if (mark >= 40) grade = 'D';
else if (mark < 40) grade = 'F';
System.out.println ("Grade = " + grade);
if (mark > 100) (System.out.pri ntln ("Invalid Entry"));
can't figure why ..
The program however runs, and if the user enters "101" for exmple, it keeps obeying the second 'else if'....
Any ideas pls....?
thanks

Comment