Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help needed in Java

 
Deepak Lal
Ranch Hand
Posts: 561
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a clarification in java.

Requirement:
1>Write a method in java such that it returns a number between 0 and 3 ?
2>Using the same above method as defined in step#1,generate a number between 0 and 7 ?

Please help me out to solve this .

--
Deepak Lal
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please help me out to solve this .

What do you have so far ? (please read this)
 
Campbell Ritchie
Sheriff
Posts: 48917
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Christophe Verré wrote:(please read this)
And this. And this.
 
Deepak Lal
Ranch Hand
Posts: 561
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI campbell and christophe,
i read your link.but i dont know how to proceed for this particualar problem.could you guide me please.?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15272
37
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A method in Java that returns a number between 0 and 3:

Or is there more to the assignment than this? Did you mean a random number between 0 and 3? If so, then have a look at the API documentation for class java.lang.Math. It contains a method to generate random numbers. Or look at the documentation of class java.util.Random.

It sounds like a very simple exercise. Can explain in more detail what you don't understand about it?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a part from this page that I'd like to draw your attention to :
We would much rather see you post your own code, working or not, and give you tips to help you get it working or point you toward resources that will help you to learn how to solve your problem using best practices.
 
Deepak Lal
Ranch Hand
Posts: 561
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok,
i will post my code and then please guide me to resolve it.
Thanks everyone.

--
Deepak Lal
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic