Could someone show me coding for the following: - I need to know how to show a dialog box that allows the user to enter there FIRST Name, Once they have done that and clicked Ok, the user must enter the range of numbers that are to be used to generate the random number the user has to guess. First enter the minimum number. Ensure that this entry is numeric. If not generate an appropriate error message, and ask the user to re-enter it. This will require some sort of loop that keeps asking for a valid minimum number until one is entered! Once the minimum number has been successfully entered, prompt for the maximum number in the range of numbers to be guessed atAgain, ensure that the maximum number entered is a valid integer. Also, ensure that the maximum number is greater than the minimum number, i.e., range 200 ? 10, is an invalid range!
Once both the minimum and maximum values of the range of numbers to be guessed at and have been successfully entered, calculate the expected minimum number of guesses it should take to guess a random number within the given range. To calculate 25 in Java, use: Math.pow( 2, 5 ); ALL COnfusing for me, if anyone can understand it, ur one genius, this is for GUESS THE NUMBER, i have started it off, but not able to finish it without this. here is my coding, mite help import java.applet.Applet; import java.awt.*; import java.awt.event.*;
public class guessnumber extends Applet implements Runnable, ActionListener { int Count = 0; String msg; Thread t = null; int state; boolean stopflag; private Label l1, l2; private TextField t1, t2; private Button b1; private int num, mynum, diff, red, blue, green, chance = 0; private Color c;
public void init() { c = new Color( 0, 80, 0 ); setForeground( c ); l1 = new Label("I have kept a number between 1 and 1000."); l2 = new Label("Can you guess this number?"); t1 = new TextField(10); t2 = new TextField(10); b1 = new Button("Play Again"); t2.setEditable(false); add(l1); add(l2); add(t1); add(t2); add(b1);
t 1.addActionListener(this); b1.addActionListener(this); num = 1 + (int) (Math.random()*1000); }
public void start() { msg = getParameter( "Guess The Number?" ); if(msg == null) { msg = "Guess number"; } msg = " " + msg; t = new Thread( this ); stopflag = false; t.start(); }
What is the question ? I don't mind to spend some time to help but YOU need to spend some time to simplify the matter to show us what is your real problem. The site is not a code factory but a place where you can find help.
this is the question allow the player to enter their first name and the number range to use (e.g., 1 - 100, 20 - 2000, etc...) Change the output to display the player's name as well as the appropriate output message. i aslo need to Calculate the number of guesses that a player should take to find the random number given the inputted range, and use this value, rather than 10, when deciding which of the three final output messages to display when the player successfully guesses the random number.