Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2008

Tip: Looking for answers? Try searching our database.

java code

Thread view: 
Vishal - 25 Mar 2008 16:50 GMT
i want the code for this program :

54444
54333
54322
54321
Thomas Kellerer - 25 Mar 2008 16:52 GMT
Vishal, 25.03.2008 16:50:
> i want the code for this program :
>
> 54444
> 54333
> 54322
> 54321

public class UselessCode
{
 public static void main(String[] args)
 {
   System.out.println("54444");
   System.out.println("54333");
   System.out.println("54322");
   System.out.println("54321");
 }
}
Steve Wampler - 25 Mar 2008 17:17 GMT
> Vishal, 25.03.2008 16:50:
>> i want the code for this program :
[quoted text clipped - 14 lines]
>  }
> }

I'm pretty sure that can't be right.  There isn't enough
computation involved.  *This* code however, has
enough computations to be right:

public class Foo {

    public static void main(String args[]) {
        int value;
        while ((value = aNumber()) != 54444);
        System.out.println(""+value);
        while ((value = aNumber()) != 54333);
        System.out.println(""+value);
        while ((value = aNumber()) != 54322);
        System.out.println(""+value);
        while ((value = aNumber()) != 54321);
        System.out.println(""+value);
        }

    public static int aNumber() {
        if (null == rand) rand = new java.util.Random();
        int result = 0;
        for (int i = 0; i < 5; ++i) {
            result = (10*result)+rand.nextInt(5)+1;
            }
        return result;
        }

    private static java.util.Random rand = null;
    }

Signature

Steve Wampler -- swampler@noao.edu
The gods that smiled on your birth are now laughing out loud.

Lord Zoltar - 25 Mar 2008 18:29 GMT
> > Vishal, 25.03.2008 16:50:
> >> i want the code for this program :
[quoted text clipped - 48 lines]
> Steve Wampler -- swamp...@noao.edu
> The gods that smiled on your birth are now laughing out loud.

It's not nearly enterprisey enough. You should implement an EJB to
generate the random numbers. When one of the required numbers is
found, it should be persisted to a database (and also loaded into a
cache, which should be periodically updated from the database). The
interface to this program should be a webservice.
:P
Lord Zoltar - 25 Mar 2008 18:31 GMT
> It's not nearly enterprisey enough. You should implement an EJB to
> generate the random numbers. When one of the required numbers is
> found, it should be persisted to a database (and also loaded into a
> cache, which should be periodically updated from the database). The
> interface to this program should be a webservice.
> :P

...oh yeah, you should try to find a way to involve a mainframe that
stores the random numbers and gets updated in a daily batch cycle.
Daniel Pitts - 29 Mar 2008 04:16 GMT
>> It's not nearly enterprisey enough. You should implement an EJB to
>> generate the random numbers. When one of the required numbers is
[quoted text clipped - 5 lines]
> ....oh yeah, you should try to find a way to involve a mainframe that
> stores the random numbers and gets updated in a daily batch cycle.
*Looks forward to the bug report*:

Summary: Please increase random number generation count.
Description:
  We're getting the exception
com.enteprisey.ejb.tpsreports.random.InsufficientNumbersException on a
daily basis now.  Could we double the daily batch cycle please?

Signature

Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>

Mike  Schilling - 25 Mar 2008 19:11 GMT
>>> Vishal, 25.03.2008 16:50:
>>>> i want the code for this program :
[quoted text clipped - 54 lines]
> cache, which should be periodically updated from the database). The
> interface to this program should be a webservice.

And to make it more efficient you need to move the "10*result" calculation
into a C native method and call it via JNI.
Andrew Thompson - 26 Mar 2008 09:56 GMT
On Mar 26, 5:11 am, "Mike  Schilling" <mscottschill...@hotmail.com>
wrote:
...
> And to make it more efficient ...

..Oh (plaintiff whine) You 'guys' are not 'nice'.

ROTFL  ;-)

--
Andrew T.
PhySci.org
Arved Sandstrom - 26 Mar 2008 18:40 GMT
On Mar 25, 12:17 pm, Steve Wampler <swamp...@noao.edu> wrote:
> Thomas Kellerer wrote:
> > Vishal, 25.03.2008 16:50:
[quoted text clipped - 49 lines]
> Steve Wampler -- swamp...@noao.edu
> The gods that smiled on your birth are now laughing out loud.

It's not nearly enterprisey enough. You should implement an EJB to
generate the random numbers. When one of the required numbers is
found, it should be persisted to a database (and also loaded into a
cache, which should be periodically updated from the database). The
interface to this program should be a webservice.
:P

I figure there has to be a way to involve REST in this. Therefore I propose
that whenever you need integers in a program, you just access an integer
server (preferably part of a massive server farm someplace) a la:

http://numbers.com/integer/decimal/54444
http://numbers.com/integer/decimal/54443
http://numbers.com/integer/decimal/54442
http://numbers.com/integer/decimal/54441

AHS
Lew - 26 Mar 2008 02:44 GMT
>         while ((value = aNumber()) != 54444);
>         System.out.println(""+value);

What's wrong with simply issuing
  System.out.println( value );
?

It seems like you're causing an awful lot of overhead by insisting on a String
concatenation where none is required.

Incidentally, the empty loop is much easier to read, and interpret correctly,
if you do not omit the braces.

  while ((value = aNumber()) != 54444)
  {}

Signature

Lew

Steve Wampler - 26 Mar 2008 04:03 GMT
> Incidentally, the empty loop is much easier to read, and interpret
> correctly, if you do not omit the braces.
>
>   while ((value = aNumber()) != 54444)
>   {}

Why on earth would I want this program to be easier to read?! :)
Lew - 26 Mar 2008 05:46 GMT
>> Incidentally, the empty loop is much easier to read, and interpret
>> correctly, if you do not omit the braces.
[quoted text clipped - 3 lines]
>
> Why on earth would I want this program to be easier to read?! :)

Precisely.

Signature

Lew

Roedy Green - 25 Mar 2008 20:12 GMT
On Tue, 25 Mar 2008 08:50:40 -0700 (PDT), Vishal
<ladduvishal2000@gmail.com> wrote, quoted or indirectly quoted someone
who said :

>i want the code for this program :

I don't believe you.  Nobody needs such a program. That is  a homework
exercise.  Asking for a solution is like asking someone to do pushups
for you.  The pushups are valueless in themselves.  They benefit only
the person who does them.

See http://mindprod.com/jgloss/homework.html
Signature


Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.