0 Members and 1 Guest are viewing this topic.
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(); }}
(number % 2 == 0)
(number > 0)
wouldn't Code: [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 do Code: [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:http://paste.ubuntu.com/5594613/Sorry I use ubuntu paste just to ensure that thread isn't spammed with code.
NumberEvaluator.main(null);