Hi, I'm stuck at the very beginning of my current assignment. I just need a little help getting started, and then I know how to do everything else.
ask user:
"Please enter your name followed by a positive integer between 1 and 9999 enclosed in parentheses, such as Cupid(1442)."
how do i use substring to take out just the name that they enter, so that it starts at the first letter they enter, and ends at the (?
also
how do i use the input integer (1442) as a seed for my random number generator?
Random rand = new Random(number);
randNum = rand.nextInt(9) ;
thanks in advance...this is a description of the assignment in case what I have said is not clear:
"Use JOptionPane to design a simple English language sentence generator with a random component, so that the user never knows quite what to expect for the output sentence, unless one “special” name is entered. This sentence generator should read expressions composed of a person’s name followed by a positive integer between 1 and 9999 enclosed in parentheses, such Cupid(1442). For output, it should produce a complete sentence about the person, such as “Cupid is a great Java programmer!” The procedure for completing the sentence is as follows:
The program should pass the input integer as a “seed” to a pseudo-random number generator object (see below).
The random number generator will use the seed to produce a single-digit integer between 0 and 9 as output.
Write your program so that the sentence completion is based upon the output random integer, or a match with the “special” name.
To reduce the number of sentences that you have to code, you may use one sentence completion for multiple random integers or “special” name match, as shown in the examples below:
Random number is 0, 1, or 2: “ is new to Java, and so his code is sometimes off target.”
Random number is 3, 4, or 5: “ is right on the mark with his Java conditional statements.”
Random number is 6, 7, or 8: “ really knows how to pair up a great algorithm with great code!”
Input name matches defined “special” name, or random number is 9: “, you’re the best!”"
ask user:
"Please enter your name followed by a positive integer between 1 and 9999 enclosed in parentheses, such as Cupid(1442)."
how do i use substring to take out just the name that they enter, so that it starts at the first letter they enter, and ends at the (?
also
how do i use the input integer (1442) as a seed for my random number generator?
Random rand = new Random(number);
randNum = rand.nextInt(9) ;
thanks in advance...this is a description of the assignment in case what I have said is not clear:
"Use JOptionPane to design a simple English language sentence generator with a random component, so that the user never knows quite what to expect for the output sentence, unless one “special” name is entered. This sentence generator should read expressions composed of a person’s name followed by a positive integer between 1 and 9999 enclosed in parentheses, such Cupid(1442). For output, it should produce a complete sentence about the person, such as “Cupid is a great Java programmer!” The procedure for completing the sentence is as follows:
The program should pass the input integer as a “seed” to a pseudo-random number generator object (see below).
The random number generator will use the seed to produce a single-digit integer between 0 and 9 as output.
Write your program so that the sentence completion is based upon the output random integer, or a match with the “special” name.
To reduce the number of sentences that you have to code, you may use one sentence completion for multiple random integers or “special” name match, as shown in the examples below:
Random number is 0, 1, or 2: “ is new to Java, and so his code is sometimes off target.”
Random number is 3, 4, or 5: “ is right on the mark with his Java conditional statements.”
Random number is 6, 7, or 8: “ really knows how to pair up a great algorithm with great code!”
Input name matches defined “special” name, or random number is 9: “, you’re the best!”"
Comment