1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Allushta [10]
3 years ago
12

Create a method called randomValues that uses a while loop to generate a random number between 1-25 until the value 10 is genera

ted. Therefore, 10 will be the value that stops your loop from generating a random number.
Computers and Technology
1 answer:
ahrayia [7]3 years ago
3 0

Answer:

The method in Java is as follows:

public static void randomValues(){

    Random r = new Random();

    int sentinel = 10;

    int randNum = r.nextInt(24) + 1;

    while(randNum!=sentinel){

        System.out.print(randNum+" ");

        randNum = r.nextInt(24) + 1;

    }

    System.out.print(sentinel);

}

Explanation:

This defines the method

public static void randomValues(){

This creates a random object, r

    Random r = new Random();

This sets the sentinel value to 0

    int sentinel = 10;

This generates a random number

    int randNum = r.nextInt(24) + 1;

This loop is repeated until the the random number is 10

    while(randNum!=sentinel){

Print the generated number

        System.out.print(randNum+" ");

Generated another random number

        randNum = r.nextInt(24) + 1;     }

Print the sentinel (i.e. 10)

    System.out.print(sentinel);

}

You might be interested in
A new object of type list is created for each recursive invocation of f.A. TrueB. False
sammy [17]

Answer:

True but double check!

7 0
3 years ago
Python 4.5 code practice
Arada [10]

Answer:

add the question

Explanation:

3 0
3 years ago
What is the difference between a syntax error and a logical error?
RoseWind [281]
A syntax error can be a simple mistake as a typo or an extra space. A logical error has to do with the code structure, and if it makes sense.

Hope this helps!
5 0
3 years ago
Anyone know how to do this?
Vsevolod [243]

Explanation: What is the class for??

5 0
2 years ago
Read 2 more answers
(Game Design) One of the most common mistakes developers make is:
german

A: Making games too Customizable

5 0
3 years ago
Read 2 more answers
Other questions:
  • I NEED HELP!!!
    9·2 answers
  • A spreadsheet can be filtered only by one column at a time? <br> true or false
    14·2 answers
  • Write a try block in which you prompt the user for an integer and display the name in the requested position in the names array.
    11·1 answer
  • Why am I constantly getting bombarded with brainly plus ads and how to fix this without paying for it?
    13·2 answers
  • The CTRL, ALT, and WINDOWS keys are commonly used for keyboard shortcuts, which are keystrokes that can quickly perform an opera
    9·1 answer
  • Place the steps in order for manually creating a New Contact Group
    10·2 answers
  • Write a JavaScript program to create a multiplication table for numbers 1 to 12 using a while loop. I’ll mark brainliest, thanks
    9·1 answer
  • Create a Python program that computes the cost of carpeting a room. Your program should prompt the user for the width and length
    10·1 answer
  • Write a function that takes as input a single parameter storing a list of integers and returns the minimum, maximum, and average
    15·1 answer
  • In what way can a costume be deleted ?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!