# Thread: "else" without "if" error

1. Member
Join Date
Nov 2010
Posts
40
Rep Power
0

## "else" without "if" error

Wow i've googled this and still can't figure out whats the matter? any assistance would be very nice. Thank you.

Java Code:
```import java.util.Scanner;
public static void main(String[] args)	{
Scanner result = new Scanner( System.in );

int numofassi;

System.out.println("How many assignments are being graded?");
numofassi = result.nextInt();

if (numofassi == 2)	{
}	elseif (numofassi == 3)	{
}	elseif (numofassi == 4)	{
}	elseif (numofassi == 5)	{
} else
{
System.out.println("Error");
}

}

Scanner two = new Scanner(System.in);
int g1;
int g2;

g1 = two.nextInt();
g2 = two.nextInt();

int average = (g1 + g2) / 2;
System.out.println("The students average is " + average);
}

Scanner three = new Scanner(System.in);
int g1;
int g2;
int g3;

g1 = three.nextInt();
g2 = three.nextInt();
g3 = three.nextInt();

int average = (g1 + g2 + g3) / 3;
System.out.println("The students average is " + average);
}

Scanner four = new Scanner(System.in);
int g1;
int g2;
int g3;
int g4;

g1 = four.nextInt();
g2 = four.nextInt();
g3 = four.nextInt();
g4 = four.nextInt();

int average = (g1 + g2 + g3 + g4) / 4;
System.out.println("The students average is " + average);
}

Scanner five = new Scanner(System.in);
int g1;
int g2;
int g3;
int g4;
int g5;

g1 = five.nextInt();
g2 = five.nextInt();
g3 = five.nextInt();
g4 = five.nextInt();
g5 = five.nextInt();

int average = (g1 + g2 + g3 + g4 + g5) / 5;
System.out.println("The students average is " + average);
}

}```

And here is the error from the compiler....

Java Code:
```sean@Port-nix-system:~/programming/java_source\$ javac grade.java
}	elseif (numofassi == 3)	{
^
}	elseif (numofassi == 4)	{
^
}	elseif (numofassi == 5)	{
^
} else
^
4 errors```

2. Senior Member
Join Date
Oct 2010
Location
Germany
Posts
787
Rep Power
8
elseif != else if

3. There is no elseif in Java

4. Senior Member
Join Date
Feb 2010
Location
Ljubljana, Slovenia
Posts
470
Rep Power
8
else if, note the space between.

5. Moon, we've been ninja'ed by eRaaaaaaa.

6. Member
Join Date
Nov 2010
Posts
40
Rep Power
0
Wow I feel like an idiot... thanks a lot everyone.