import java.util.Scanner;
public class numberEvaluator {
public static int number;
public static void evaluator(){
if(number == 0){
System.out.println("Zero.");
}else if(number % 2 == 0){
System.out.println("Even.");
} else {
System.out.println("Odd.");
}
numberEvaluator.main(null);
}
public static void main(String [] args){
Scanner sc = new Scanner(System.in);
number = sc.nextInt();
numberEvaluator.evaluator();
}
}
wouldn'tCode: [Select](number % 2 == 0)
mean it's even? Pretty sure the modulos operator divides it and takes the remainder, which would mean it's an even number if divided by two and has no remainder.
If you want to see if it's positive just doCode: [Select](number > 0)
Code: [Select]import java.util.Scanner;
public class numberEvaluator {
public static int number;
public static void evaluator(){
if(number == 0){
System.out.println("Zero.");
}else if(number % 2 == 0){
System.out.println("Even.");
} else {
System.out.println("Odd.");
}
numberEvaluator.main(null);
}
public static void main(String [] args){
Scanner sc = new Scanner(System.in);
number = sc.nextInt();
numberEvaluator.evaluator();
}
}
Did this for an intro to programming class, got a hundred
Should revive this board...
Nice job!
However, your organization disgusts me. D:
I like this, but I would think there is better ways of doing this. I wouldn't say my way is better but I would do it like this:I agree, it makes more sense if you pass in the parameter. Although I find the
http://paste.ubuntu.com/5594613/
Sorry I use ubuntu paste just to ensure that thread isn't spammed with code.
NumberEvaluator.main(null);
kind of weird. I've never seen that before. It serves its purpose though. If I wanted the program to run forever I would just use an infite while loop or something.