Solved

# Learning Java TwoRandomTester

Posted on 2008-11-03
Medium Priority
190 Views
Any suggestions that would get this run , I would greatlya appreciated it.

To the expression generator.nextInt(n) will evaluate to a random integer between 0 and 1 less than n inclusive.

Determine which of the two randomly generated integers is the arger of the two and display it to the screen in a message:

"The larger of the number ____ and _____ is ____.

Output
100
The first random number picked was 13.
The second random number picked was 67
The larger of the numbers 13 and 67 was 67
**********************************************
package tworandomtester;
import java.util.Random;
import javax.swing.JOptionPane;

public class TwoRandomTester {

public static void main(String[] args)
{
String input;

Random generator = new Random();

int randNum;

randNum = generator.nextInt(-1);

JOptionPane.showMessageDialog(null, "The larger of the two numbers si that number");
}

}
0
Question by:ca1358
• 3
• 2

LVL 24

Expert Comment

ID: 22865302

It is against the rules of Expert Exchange to probide you with all answers.

I do not need 'easy' points .....................
;JOOP!
0

Author Comment

ID: 22865345
I am glad it is easy for you,  I have been at this for three days and approximately 8 hours per day on each one of these.
0

LVL 24

Expert Comment

ID: 22865661
Do not get me wrong.
We are just NOT allowed to do homework, we may help you to go further.
You are supposed to LEARN from this and to IMPROVE yourself.

But I see that you repeatedly ask the same questions.
By now you should know how to write output from a program.

;JOOP!
0

LVL 24

Expert Comment

ID: 22865668
I think you are not learning from this way to ask questions, because you do
not have enough basic knowledge.
Therefore, please first take a basic course in JAVA fundamentals.

We all took that course some day in the past.

;JOOP!
0

LVL 61

Accepted Solution

Kevin Cross earned 2000 total points
ID: 22866394
These tutorials are also helpful to get started with:
http://java.sun.com/docs/books/tutorial/

For your assignment above, you are at least trying to solve it yourself which is a start.

I would re-read the question details that you posted above and think about the variable "n" and where it should come from and how it is used.  Sometimes you may find it helpful when you have some mathematical or specific problems like this where they use math variables like take some number "n" and generate a value "a" and a value "b" then you may want to name your variables that in code to start with until you figure out the logic and then change to be more descriptive.  If you can visualize what these values are doing it is even better to start out descriptive variable names like intGivenNumber, intFirstRandomNumber, etc.

Think as you work through logic, it will help you read code more like plain english (if you don't speak english, name the variables what makes sense in your language). :) Just helps IMHO.
0

Author Closing Comment

ID: 31512612
Thank you for the direction.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
###### Suggested Courses
Course of the Month8 days, 11 hours left to enroll