The java interpreter keeps on spitting out this error whenever I access Scanner.nextDouble() NumEvOdd.java:10: error: non-static method nextDouble() cannot be referenced from a static context double num = Scanner.nextDouble();
DecimalFormat df = new DecimalFormat("#.0");
Scanner input = new Scanner(System.in);
System.out.println("Put in your number");
double num = Scanner.nextDouble();
double numHalf = num/2;
switch (df.format(numHalf))
{
case 0:
System.out.println("Your number is even");
break;
default:
System.out.println("Your number is odd");
break;
DecimalFormat df = new DecimalFormat("#.0");
// input is an instance of class Scanner
Scanner input = new Scanner(System.in);
System.out.println("Put in your number");
// double num = Scanner.nextDouble();
// This is wrong, .nextDouble() is a method for a Scanner Object,
// this needs to be our input object we created above
double num = input.nextDouble();
double numHalf = num/2;
switch (df.format(numHalf))
{
case 0:
System.out.println("Your number is even");
break;
default:
System.out.println("Your number is odd");
break;
...