ei guys can you help me to make a program?
that gives a random number from 1-10 and the user will guess what will be the output number and can only try three times?
i have no idea on how to make this.. help me out please..
Printable View
ei guys can you help me to make a program?
that gives a random number from 1-10 and the user will guess what will be the output number and can only try three times?
i have no idea on how to make this.. help me out please..
Yes we can help, we get plenty of this from today's coder. What books are you reading? Do you want to learn something or just get by a class instruction? I can help either way, but first: Do you know what a random number is?
newbies, oh the fun!
yes it gives a random number w/out knowing what number will appear
can you show the codes for that problem? so i can try it and simulate in my pc
actually i am studying java for only a month a college student. and we have this project . a
"Just one month". After my first month we had already covered inheritance, polymorphism, swing, file i/o etc. I promise you you have covered this in your classes.
The first thing you should to is check Java's API. You want to create a random number? What do you think Sun have named the class that handles just that? Also Google is a tip.
And when you have a concrete question about your code to ask, you're welcome to post again.
Break the program up into small steps:
First generate a random number
Write a test program that does only this. Use println() to display the results.
Next ask user to guess
Write another test program that only does this.
Get user response
Same as above.
After you have done the above come back with your questions on how to continue.
Good luck.
i really dont get it T_T
can help me on what code should I put ?
No, no one is going to do your homework for you. That does not help you, no matter how hard you want to think it will. Read my last post again.
im not asking you to make my homework
im just asking what code will i put
btw thank you for the time that you spent replying in this thread
im just hoping that someone can give the codes to me T_T thank you in advance T_T
signing off
Ok, we'll get you started:Code:public class MyClass {
public static void main(String[] args) {
System.out.println("Starting main"):
//.... put YOUR logic here
} // end main
// Put needed methods here
} // end class
Covered inheritance & polymorphism? What's that, lol. ;)
Because I'm in a good mood I'll help you, a little.
java.lang.Math.random() generates a random number between 0 and 1. Math.random() < 1
Basically you have to write some code, that is what the other posters are trying to say. If that is hard, just write some code - eventually the solution, as that may be, appears on the screen as though you had actually done some thinking. At that point, the other's harping will sound like music, which you can probably use given your displayed name.