Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 [HELP]JAVA question,How to do this?, JAVA

views
     
TSj4053
post Jun 28 2016, 02:24 PM, updated 8y ago

New Member
*
Newbie
3 posts

Joined: Dec 2014


Question: Write a Java program to list out all possible even numbers that exists in between 1000 to 9999 and the digits exit in each of the even numbers shall not be repeated.

Sample of output:-
-----------------------
List of even without repeated digit
1024
1026
1028
1032
1034
1036
1038
1042
...
...
...
9874
9876


Requirement:-
i)Coding
ii)Comments
iii)Implementation of object-oriented concept

This post has been edited by j4053: Jun 28 2016, 02:25 PM
alien3d
post Jun 28 2016, 02:28 PM

Look at all my stars!!
*******
Senior Member
3,740 posts

Joined: Mar 2009
zzzz
xsan
post Jun 28 2016, 02:53 PM

Ouh Emm Gee I Can Edit This Nao
******
Senior Member
1,020 posts

Joined: Jul 2006
From: Bastion Keep


anything wrong with your code?
share it here please..
TSj4053
post Jun 28 2016, 03:47 PM

New Member
*
Newbie
3 posts

Joined: Dec 2014


QUOTE(xsan @ Jun 28 2016, 02:53 PM)
anything wrong with your code?
share it here please..
*
what?
i dont understand...
donald88
post Jun 28 2016, 03:51 PM

Casual
***
Junior Member
357 posts

Joined: Sep 2008


First figure out the algorithm la then only work on the coding
xsan
post Jun 28 2016, 04:22 PM

Ouh Emm Gee I Can Edit This Nao
******
Senior Member
1,020 posts

Joined: Jul 2006
From: Bastion Keep


QUOTE(j4053 @ Jun 28 2016, 03:47 PM)
what?
i dont understand...
*
duh show me ur codes..
people can fix it..

if u ask how to do it, first generate the number.. after that u use algorithm to ensure no repeatable number..
SUSRaymondReddington
post Jun 28 2016, 05:11 PM

Getting Started
**
Junior Member
91 posts

Joined: Apr 2016
Another homework request.

I'll only give you a simple tip.


Modulus operator.

If you still can't figure it out, please quit your course and stop contributing to the pool of unqualified candidates therefore making tech interviews broken because of people like you.

angch
post Jun 28 2016, 08:34 PM

On my way
****
Junior Member
635 posts

Joined: Jul 2006
CODE
perl -e 'print map{"$_\n"}grep(!/(\d).?(\1)/&&!($_&1),1000..9999)#prints (MapReduce!!!!!one1)with newline all (nonrepeating digits and nonodd) numbers from 1000 to 9999'


Sorry, I don't do Java.

This post has been edited by angch: Jun 28 2016, 08:41 PM
dewill
post Jun 28 2016, 08:38 PM

Regular
******
Senior Member
1,716 posts

Joined: Feb 2006


1. configure the janjang arimetik
2. code the iteration with a limit
malleus
post Jun 28 2016, 09:29 PM

Look at all my stars!!
*******
Senior Member
2,096 posts

Joined: Dec 2011
QUOTE(angch @ Jun 28 2016, 08:34 PM)
CODE
perl -e 'print map{"$_\n"}grep(!/(\d).?(\1)/&&!($_&1),1000..9999)#prints (MapReduce!!!!!one1)with newline all (nonrepeating digits and nonodd) numbers from 1000 to 9999'


Sorry, I don't do Java.
*
lemme help with the java bit then. smile.gif

CODE

public static void main(String[] args) {
   Runtime rt = Runtime.getRuntime();
   rt.exec("perl -e 'print map{"$_\n"}grep(!/(\d).?(\1)/&&!($_&1),1000..9999)#prints (MapReduce!!!!!one1)with newline all (nonrepeating digits and nonodd) numbers from 1000 to 9999'");
}

angch
post Jun 28 2016, 11:26 PM

On my way
****
Junior Member
635 posts

Joined: Jul 2006
QUOTE(malleus @ Jun 28 2016, 09:29 PM)
lemme help with the java bit then.  smile.gif

*
Nice! But you need to escape the quotes.

CODE

public static void main(String[] args) {
   Runtime rt = Runtime.getRuntime(); // OOP. rt is an instance of the class "Runtime"
   rt.exec("perl -e 'print map{\"$_\\n\"}grep(!/(\\d).?(\\1)/&&!($_&1),1000..9999)#prints (MapReduce!!!!!one1)with newline all (nonrepeating digits and nonodd) numbers from 1000 to 9999'");
}


malleus
post Jun 28 2016, 11:57 PM

Look at all my stars!!
*******
Senior Member
2,096 posts

Joined: Dec 2011
QUOTE(angch @ Jun 28 2016, 11:26 PM)
Nice! But you need to escape the quotes.

CODE

public static void main(String[] args) {
   Runtime rt = Runtime.getRuntime(); // OOP. rt is an instance of the class "Runtime"
   rt.exec("perl -e 'print map{\"$_\\n\"}grep(!/(\\d).?(\\1)/&&!($_&1),1000..9999)#prints (MapReduce!!!!!one1)with newline all (nonrepeating digits and nonodd) numbers from 1000 to 9999'");
}

*
oh yeah that's right. didn't notice the double quotes in your snippet

 

Change to:
| Lo-Fi Version
0.0140sec    0.35    5 queries    GZIP Disabled
Time is now: 28th March 2024 - 08:04 PM