I'm trying to complete my java assignment Java- 2 (Even Or Odd ). But I don't know if I'm even writing the code right at all. Every time that I run my code it print out even without typing anything. I'm just making sure that I'm doing everything right, so that I can move on to the next assignment. Thank you for your help!! Here is what the assignment says :
Write a program that will read in a number from the command line and tell me if it is even or odd. In other words, I want to type java EvenOrOdd 28 and see even.
You are always passing the number 28, so it will always think it is even. You can pass
java MyEvenOrOdd 123 before you run the program. In that wase you would expect "123" to be args, and you will suffer en Exception if you try to pass 1.234 or if you miss out the number. You can read more about the command line in the Java Tutorials (I/O section).
Joined: Sep 21, 2013
Thank you for the help and for the link!! I now know that the code is working fine now.
Just a general note - we really like it if you tell us where you get your problems. It's really only polite to the owner. Plus, if it is from something like a web site, it allows us to check that you have copied it correctly.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors