this is the code
the if (grade >= 40 && <= 90) is underlined saying... illegal start of expression
*/
package testing;
import java.util.Scanner;
/**
*
* @author Dokun
*/
public class NewClassIfmethod {
private String courseName;
//starting a constructor
public NewClassIfmethod (String name){
courseName = name;
}
//endin the constructor
//creating a new method setNewClassIfmethod
public void setNewClassIfmethod (String name){
courseName = name;
}
// creating a method to getNewClassIfmethod
public String getNewClassIfmethod(){
return courseName;
}
public void displayMessage(){
System.out.printf("Welcome to the world of Java programing %s\n\n" , getNewClassIfmethod());
}
public void averageGradeTest(){
Scanner input = new Scanner (System.in);
int grade;
int total;
int gradecounter;
double average;
total = 0;
gradecounter = 0;
//promt user
System.out.println("Enter Grade Number or -1 exit");
grade = input.nextInt();
// inserting entinel
while (grade != -1){
total = total + grade;
gradecounter = gradecounter + 1;
System.out.println("Enter Grade Number or -1 exit\n");
grade = input.nextInt();
}
if (gradecounter != 0){
average = (double) total/gradecounter;
System.out.printf("The Class Average %.2f\n", average);
System.out.printf("The grade total is %2d\n", total, gradecounter);
}
else
{
System.out.println("No grade Entered");
}
if (grade >= 40 && <= 90){
System.out.println("The number of " + gradecounter + " passed the Exam" );
}
else {
System.out.println("The number of " + gradecounter + "failed the exams");
}
}
}
--- Update ---
Thanks guys
I have seen it that grade is missing from if (grade >= 40 && <= 90){