Hello,
I am having trouble with my Odd/ Even Code. Can anyone help me with this? Or has a current code?

where is your odd/even code ... let us have a look over it. Only then we'll be able to help you.

Hello,
I am having trouble with my Odd/ Even Code. Can anyone help me with this?

Here is what I have so far, but the program is not recognizing the (number) after if ( number). So if anyone can help I would sure appreciate it.

mport javax.swing.JOptionPane;  // program uses JOptionPane
public class EvenOdd {
/** Creates a new instance of EvenOdd */
public EvenOdd() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String firstNumber;    // first string entered by user
int number;           // number to be read
int even;            // number if even
int odd;             // number if odd
firstNumber = JOptionPane.showInputDialog( null, " Enter a number" );
if ( number%2 == 0 );
System.out.print( " Number is EVEN " );

Edited 3 Years Ago by happygeek: fixed formatting

Well, you are trying to use "number" in your if statement. You do not have number set to any value. Maybe you meant "firstNumber" instead of "number".That should get you going in the right direction

Edited 3 Years Ago by happygeek: fixed formatting

try it now

import javax.swing.JOptionPane; // program uses JOptionPane

public class EvenOdd {

   public static void main(String[] args) {
	  String firstNumber; 
	  int number; 

	  firstNumber = JOptionPane.showInputDialog( null, " Enter a number" );
	  number = Integer.parseInt(firstNumber);
	  
	  if ( number%2 == 0 ){
		 System.out.print( " Number is EVEN " );
	  }
	  else 
		 System.out.print("Number is ODD");
   }
}

Can any one help me Plz
- write an java program that outputs the followingpattern. Th program should prompt the user an osdd nmbr of lines (limit 1 to 11).
For example, if the user prompt the number of lines is 9, the the outputs should be :
+
++
+++
++++
+++++
++++
+++
++
+

import java.util.*;
import java.io.*;

public class kaze{
     public static void main(String[] args) throws IOException{
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

      Integer number;
      System.out.println("Input A Number:"); 
      number = Integer.parseInt(in.readLine());


      if (number % 2 == 0)
      {
        System.out.println(" Even.");
      }
      else
      {
        System.out.println(" Odd.");
      }
    }
}

Edited 3 Years Ago by mike_2000_17: Fixed formatting

import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Number;

public class OddEven{

	public static void main(String[] args)throws Exception{
	
		BufferedReader bufRead = new BufferedReader(new InputStreamReader(System.in));

		String strNumber;
		int number=2;
		System.out.println("Enter a number:");
		strNumber = bufRead.readLine();
		number = Integer.parseInt(strNumber);


		if (number % 2 == 0)
		{
			System.out.println(" Even Number Entered is : "+number);

			for(int i=0; i < number ; i++)
			{
				for(int j=0 ; j< i ; j++)
				{
					System.out.print("+");
				}
			System.out.println("");
			}

			for(int i=number ; i >0 ; i--)
			{
				for(int j=i ; j >0 ; j--)
				{
					System.out.print("+");
				}
			System.out.println("");
			}

		}
		else
		{
			System.out.println(" Odd Number Entered is : "+number);
			for(int i=0; i < number ; i++)
			{
				for(int j=0 ; j< i ; j++)
				{
					System.out.print("+");
				}
			System.out.println("");
			}

			for(int i=number ; i >0 ; i--)
			{
				for(int j=i ; j >0 ; j--)
				{
					System.out.print("+");
				}
			System.out.println("");
			}

		}
	System.out.println("------------------Thank You --------------------------------");
	}
}

new_programmer

This article has been dead for over six months. Start a new discussion instead.