Conjoint Gaming [Game On]
CG Technical Area => Programming => Topic started by: Mr. Commodore on May 05, 2012, 06:13:56 AM
-
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 Meme6
Should revive this board...
-
wouldn't
(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
(number > 0)
-
wouldn't (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
(number > 0)
That would be a derp on my use of words, positive = even, negative = odd.
-
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 Meme6
Should revive this board...
Nice job!
However, your organization disgusts me. D:
-
Nice job!
However, your organization disgusts me. D:
That's due to Dr. Java. I NEVER want to use it, but for the purposes for the class its really helpful in debugging.
-
Dude, get eclipse.
-
Ya really why are you using Dr. Java eclipse is 100 times better
-
Have and do use eclipse.
For the purpose of a few assignments in the class that involve manipulating objects in a 2d environment, the interactions pane is actually REALLY helpful. Only really use it for fine tuning what I do in eclipse, and it puts it in a retarded format.
-
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.
-
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.
I agree, it makes more sense if you pass in the parameter. Although I find the
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.
That post was quite a necro by the way. This thread is like 10 months old. The board does still need more posting.
-
10 month old necro. I will hurt someone, by God.
(http://www.novarata.net/thread_necromancer_0.jpg)
Locked.