# Extract odd numbers and verify there is an odd number of them

Page 1 of 1

## 1 Replies - 630 Views - Last Post: 28 January 2011 - 10:03 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=212685&amp;s=0bdbfd4f7b65659c6403f2ced2ceadf5&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 gracie891

Reputation: 0
• Posts: 1
• Joined: 28-January 11

# Extract odd numbers and verify there is an odd number of them

Posted 28 January 2011 - 07:48 PM

Hi
I have written the below code and I am supposed to do several things, one is ensure its a 6 digit number, which seems to work. Second is where there are errors, I need to determine there are an odd number of odd numbers:

I keep getting that the else statement needs an if..which it seems to have and either exit code 1 or 2 depending on how I manipulate things.

```import javax.swing.JOptionPane;		//Allows for JOptionPane to be initiated

public static void main(String[] args) {

String inputString;

inputString =

passInput = Integer.parseInt(inputString);

if (inputString.length()== 6)
{
System.out.println("Input:"+inputString);
System.out.println("End of Processing.");

}
else if(inputString =(int) n%10);

if (inputString %2 == 1)  // if digit is odd
{
result += digit * Math.pow(10,power);
power++;
}
n/=10;

{
System.out.println("Input:"+inputString);
System.out.println("End of Processing.");
}
else
{
System.out.println("Input:"+inputString);
System.out.println("End of Processing.");

}

System.exit(0);
}
}
```

Edited by Dogstopper:

Is This A Good Question/Topic? 0

## Replies To: Extract odd numbers and verify there is an odd number of them

### #2 macosxnerd101

• Games, Graphs, and Auctions

Reputation: 12176
• Posts: 45,242
• Joined: 27-December 08

## Re: Extract odd numbers and verify there is an odd number of them

Posted 28 January 2011 - 10:03 PM