Project 8: Random Number
Before you begin, create a folder in your Projects Folder called Firstname.LastName.project8. Do a File...Save as this html document into your Project8 folder. Comment out each line or section of java code on anything you do using the /* (insert comments here) and */ symbols.
Intro: To do this applet you will need to utilize:
- the Math.random() method. It returns a value between 0 and 1 as a floating point number. To convert it to an integer object, you will need to "cast" the float to an integer(look it up).
- create a button object ... Not too tough. Look up the Button class in the javadocs.
- make Math.random() run when they click the button ... a little tougher. You will need to run a method like public boolean mouseDown(Event evt,int x,int y) and get it to work only when they mousedown on the button object. Or use addActionListener() and actionPerformed() methods.
1. Create an applet in the space below that generates a random number between 1 and 100 when the user click a button. You will need to import java.applet, java.awt, and maybe java.util.
Save a copy of your entire folder into the Project 7 Folder on the server. You should have a project7.java file, a project7.class file and a project7.htm file.
Make sure the folder has your Firstname.Lastname.project7 as a title. Open up your project on the server in a browser to make sure it appears the way your want it.