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]
2 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]2 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
When creating a spreadsheet, there's no need to worry about design and how it will be organized; the program will take care of t
Rainbow [258]
False: a computer program do many things, but it can't read your mind. It doesn't know what kind of formatting you need for your spreadsheet. There are so many potential layouts of a spreadsheet, that the computer couldn't decide what to lay it out for you. Eventually the computer can see what you're trying to lay it out as and can help that way, but it needs to e started first. Having a uniform sheet that is well organized by you, is much easier to read than gobbledegook that has been spewed everywhere.

I hope this was helpful!
3 0
2 years ago
Read 2 more answers
Ross has to create a presentation for his class but can't decide on a topic. What should he do?
mylen [45]
Resheach thngs that instrest him and that fit the guidlines
6 0
3 years ago
Read 2 more answers
Is a bottle opener considered an engineered item?
KIM [24]
Yes actually it is it’s a machine to use for opening bottles such as cans n other
3 0
3 years ago
In an SLR camera photogaphers look from the viewfinder through which of the following?
Fantom [35]
The answer is A mirror the lens
8 0
2 years ago
Read 2 more answers
A pointing device uses light to determine hand motion.
kirill [66]
The answer to this is Optical mouse. 

The reason the answer is optical mouse is because the optical mouse is a computer mouse which uses a light source, typically a light-emitting diode, and a light detector, such as an array of photodiodes, to detect movement relative to a surface. 

Hope this helped :)
have a great day 
3 0
2 years ago
Other questions:
  • Software development team leaders need blank skills to excel in directing their teams
    8·2 answers
  • The concept of ____ refers to the idea that the internet is designed for all content to be treated equally.
    12·1 answer
  • Microsoft ________ is a cloud storage and file sharing service
    12·1 answer
  • You asked your colleague to provide feedback on a blog post you recently wrote. When they sent you their feedback, they made edi
    10·1 answer
  • Fedora operating system
    9·1 answer
  • If you're unsure if something
    9·2 answers
  • How does natural gas move through pipelines from the well head to the end user thousands of miles away
    5·1 answer
  • If you wanted to divide an integer variable by 2, which of the following lines of code would you use? total = int + 2 total = in
    6·1 answer
  • Which game would you play info you were competitive?
    13·2 answers
  • Please solve this in JAVA<br><br> Please see the attachment
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!