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
My mac book airs touch pad stopped working and i can't click. what do i do?
julsineya [31]
Get it in to be fixed
7 0
3 years ago
Read 2 more answers
Which of the following is considered a modern method of communication?
Vika [28.1K]
The answer is C. Tablet, because that is the quickest, easiest, and most recent way of communication.
4 0
3 years ago
Read 2 more answers
1.2<br>Is media a curse or a blessing? Explain.​
Vesna [10]

<em>ANSWER: </em>i  think a blessing

<em>Explanation:</em> Social media has been ingrained into our society today to such extent that is virtually impossible for people to take you seriously, if you are not any social media platform. Everyone is on social media - young, old, rich, poor, etc. Everyone is always in a frenzy when it come to socializing online. Even the corporate world has jumped into the bandwagon and companies are very active online, posting, update and answering queries.

<u><em>HOPE THIS HELPS IF NOT SORRY</em></u>

5 0
3 years ago
Read 2 more answers
2) Prompt the user for his/her favorite 2-digit number, and the output is the square root of the number.
DochEvi [55]

num = int(input("What's your favorite 2-digit number? "))

print("The square root of {} is {}".format(num, (num**0.5)))

I hope this helps!

7 0
3 years ago
Consider the packets exchanged in TCP connection setup between Host A and Host B. Assume that Host A's initial sequence number i
Rasek [7]

Answer:

I think that part C correct option

6 0
3 years ago
Other questions:
  • Which soft skill involves the ability to work harmoniously with your colleagues and improve productivity?
    14·1 answer
  • It is a good idea to include your teacher’s name on a title page.
    15·2 answers
  • A program that contains the following method: public static void display(int arg1, double arg2, char arg3) { System.out.println(
    15·1 answer
  • What are the advantages and disadvantages of solving a problem that can be broken down into repetitive tasks with recursion as o
    13·1 answer
  • What kind of keybord is tis ned help pleese I don't no wat itis​
    11·2 answers
  • This project involves writing a program that encodes and decodes messages. The program should prompt the user to select whether
    15·1 answer
  • Explain 2 ways in which data can be protected in a home computer??
    11·1 answer
  • Please give me a answer correctly​
    10·1 answer
  • Your agile team only has one database developer. So the other developers finish their tasks and then wait for their work to be I
    6·1 answer
  • attackers typically use ack scans to get past a firewall or other filtering device. how does the process of an ack scan work to
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!