So basically this is an assignment, and i am getting the correct results when i put in my answer, however, which the system i am submitting my code to tries to enter something it receives an error saying "java.util.NoSuchElementException - ". Any ideas on whats going on? All is fine and dandy on my end :s
import java.util.Scanner;
public class SimpleCalc {
/**
@author Andrew Howard - 430365526
*/
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);/**preparing for input*/
long n = keyboard.nextLong();/** n has been used as it was what the variable name used in the assesment description*/
if (n < 0){ /**numbers less than zero*/
System.out.println(n*n+n/2);
}
if (n >= 0 ) {/**number greater than or equal to zero*/
if (n % 2 == 0){/**determines whether a number is even*/
System.out.println((n*n*n*(n-1)));
}
else {/** else is used for numbers that are not even, i.e.; odd*/
System.out.println((1/n)+3*n);
}
}
}
}