• Post Reply Bookmark Topic Watch Topic
  • New Topic

checking random generator number belong to the array is not  RSS feed

 
Nivi Chandana
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to design the following::
Softwares available :: Java/MySql


Inputs :: example

List of seqNos :: 1,2,3,4,5,6 {this list never changes}
seqNo :: 3 {randomly generated number which is always in between 1 to 6}


Requirement :

Check if you can find your list of sequence nos matches your sequence number within certain time say 2minutes, -- print you found your number
if you can not find match within certain time, --- print not found your number

you need to output
which numbers from your List of seqNos matched{found} with date and times
which numbers from your List of seqNos not matched{not found} with date and times

==================
I kind of stuck where to start really, wrote some code but not exactly it is doing what i wanted, any ideas or pointers or suggestions
welcome
i need basically some suggestions
thank you and regards
==================
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I kind of stuck where to start really, wrote some code but not exactly it is doing what i wanted, any ideas or pointers or suggestions

If you are stuck on where to start then you should not be attempting to write any code at all. Writing code should only be attempted once you have fully understood the problem and have a detailed description of how to solve it.

I suggest you sit down with a pen and paper and write out every step you would take if you had to do this. If you want you can post your written solution here and we will critique it for you.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In addition to Tony's advice, once you DO start writing code, you should never write MUCH code before you compile and test. I seriously never write more than 2-3 lines at at time. I write tons of lines I know i'm going to throw away...lines

System.out.println("calling method X");
System.out.println("entering for loop");
System.out.println("counter is " + counter);
System.out.println("method to compute value - for now always return 5");

etc.

you write the smallest chunk of code that advances your project. For example, if I needed to prompt the user, get some input, and validate it, my first iteration would do nothing more than print the prompt - it would make no effort to actually get the input. Once I compiled, ran, and tested that, I'd write the line or two to actaully get the input, and print it back out immediately with a System.out.println("user input of " + userInputString);

Once I could echo it out, THEN I'd see about validating it. you keep writing teeny tiny chunks, and test them, and your life is about a million time easier than trying to write an entire 300 line program in one go, and only then trying to debug it.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!