HELP

Write an application that reads an integer and determines and prints whether it is odd or even. [Hint: Use the remainder operator. An even number is amultiple of 2. Any multiple of 2 leaves a remainder of 0 when divided by 2.]

import java.util.Scanner;

publicclass _2_25

{

publicstaticvoid main(String[] args)

{

Scanner input =new Scanner(System.in);

int num = 0;

System.out.print("Enter an integer: ");

num = input.nextInt();

if(input.hasNextInt() %= 2)

{

System.out.print("the integer is even");

}

else

{

System.out.print("the integer is an odd");

}

}

}

I don't know how to solve this thing

[1337 byte] By [nemo666a] at [2007-11-27 11:39:17]
# 1

1) "HELP" is not acceptable as a subject line - almost all posts need "HELP"

2) Don't just post your homework question here

3) What doesn't work?

By the way, don't bother with a "if you don't know don't answer" reply, it won't wash

georgemca at 2007-7-29 17:25:13 > top of Java-index,Java Essentials,New To Java...
# 2

lol I got the logic on my own.. by the way that's not an assignment man!!

I'm trying to answer the exercises from the ebook..im a newbie working as a QA and a struggling programmer..

this is what i found out

if ((num % 2) == 0)

YEAH !!! hehehe

nemo666a at 2007-7-29 17:25:13 > top of Java-index,Java Essentials,New To Java...
# 3

> if ((num % 2) == 0)

You are on the correct path. This is the right way to check whether the integer num is odd or even.

java_knighta at 2007-7-29 17:25:13 > top of Java-index,Java Essentials,New To Java...