Outline ·
[ Standard ] ·
Linear+
[HELP]JAVA question,How to do this?, JAVA
TSj4053
|
Jun 28 2016, 02:24 PM, updated 8y ago
|
New Member
|
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
|
Jun 28 2016, 02:28 PM
|
|
zzzz
|
|
|
|
xsan
|
Jun 28 2016, 02:53 PM
|
|
anything wrong with your code? share it here please..
|
|
|
|
TSj4053
|
Jun 28 2016, 03:47 PM
|
New Member
|
QUOTE(xsan @ Jun 28 2016, 02:53 PM) anything wrong with your code? share it here please.. what? i dont understand...
|
|
|
|
donald88
|
Jun 28 2016, 03:51 PM
|
|
First figure out the algorithm la then only work on the coding
|
|
|
|
xsan
|
Jun 28 2016, 04:22 PM
|
|
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
|
Jun 28 2016, 05:11 PM
|
Getting Started
|
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
|
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. This post has been edited by angch: Jun 28 2016, 08:41 PM
|
|
|
|
dewill
|
Jun 28 2016, 08:38 PM
|
|
1. configure the janjang arimetik 2. code the iteration with a limit
|
|
|
|
malleus
|
Jun 28 2016, 09:29 PM
|
|
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. 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
|
Jun 28 2016, 11:26 PM
|
|
QUOTE(malleus @ Jun 28 2016, 09:29 PM) lemme help with the java bit then. 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
|
Jun 28 2016, 11:57 PM
|
|
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
|
|
|
|