:confused:Hey

I just started a programming class and stuck in a section of my assigment. i would like to know if someone could guide me to the right direction.

Last instruction:

" Write a script that reads an integer and determines and output XHTML text that displays whether it it odd or even.{hint: use the remainder operator. An even numder is a muiple of 2.
Any multiple of 2 leaves a remainder of zero when divided by 2.}

I would apreciate this a lot.

Moussa

You need to use if/else with the remainder operator.

//Purpose: Check if number is odd or even.
import java.util.Scanner;
public class oddeven {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner input = new Scanner (System.in);
	
		int x;
		
		System.out.print("Enter a number:");
		x = input.nextInt();
		
		if(x==0)
		
		System.out.println(x+" is even.");
		
		else if(x%2==0)
		
		System.out.println(x+" is even.");
		
		else if(x%2!=0)
		
		System.out.println(x+" is odd.");
		
}
}

hello shroomin

wow, thank you
I was wondering thought, this is for a really basic class,
This kinda of lot more advance then book showed us

does this code work in a html page
we also was told to use a (window.prompt )

haha well let me tell you somthing man, thats about as basic as its going to get. I too am in a intro to programming class, and that problem was on one of my assignments a few days ago. and were only on chapter 1 :(

but i feel your pain. i too am struggling. but im glad i was able to help you out.

edit- i have no idea if it works in a html page, we use a Java environment program called eclipse, which is a very common free program for java development.

Thank you Ezzaral
IT show you how noob i am :-(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.