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
Ugo [173]
3 years ago
5

Define global variables called highestNum, userInput and sumOfNums and initialize them. In Main call 2 methods: 1) UserData() 2)

DisplayResults()
Task #1:In the UserData() method ask the user to give you a number between 9 and 20, exclusive. Validate this input Then, create a loop that will loop THAT amount of times. Inside that loop generate a random number between 1-100. In that loop check each generated number in order to find the highest number generated. Accumulate all numbers to sumOfNums
Task #2: In the displayResults() method print the following: "There were x numbers generated" "the highest number generated is x" "The sum of the numbers is x" "The average of these numbers is x"
Computers and Technology
1 answer:
Montano1993 [528]3 years ago
5 0

Answer:

Explanation:

The following code is written in Java. It creates the two methods as requested using the Scanner and Random built-in classes in Java. Once the loop is completed and the highestNum is calculated, then the displayResults method is called to print out all the information in the correct format. The output of the program can be seen in the attached image below.

import java.util.Random;

import java.util.Scanner;

class Brainly {

   static int highestNum = 0;

   static int userInput;

   static int sumOfNums = 0;

   public static void main(String[] args) {

       userData();

       displayResults();

   }

   private static void userData() {

       Scanner in = new Scanner(System.in);

       Random rand = new Random();

       System.out.println("Enter a number between 9 and 20: ");

       userInput = in.nextInt();

       if ((userInput >= 9) && (userInput <= 20)) {

           for (int i = 0; i < userInput; i++) {

               int num = rand.nextInt(100);

               if (num > highestNum) {

                   highestNum = num;

               }

               sumOfNums += num;

           }

       }

   }

   public static void displayResults() {

       System.out.println("There were " + userInput + " numbers generated");

       System.out.println("The highest number generated is " + highestNum);

       System.out.println("The sum of the numbers is " + sumOfNums);

       int average = sumOfNums / userInput;

       System.out.println("The average of the numbers is " + average);

   }

}

You might be interested in
True or False <br><br> MAC addresses are assigned by the router along with your IP address.
Oduvanchick [21]
True. If you look at the router it will correspond with your MAC address
4 0
3 years ago
What are the three parts of a Function (Choose all 3)
dlinn [17]

Answer:

the answer is

name

return

void

7 0
4 years ago
Join this kahoot game pin 5697480
Alisiya [41]
Ok be there in a few minutes
3 0
3 years ago
Josh is searching for information online about the conservation status of blue jays. He enters the phrase blue jays and most of
Alona [7]

Answer: specify the bluejay bird

Explanation:

by specifically mentioning it is birds he wants that Is the results he will get

5 0
3 years ago
When troubleshooting a software problem on Phoebe’s computer and listening to her describe the problem, you get a text message o
Lyrx [107]

Answer:

Wait un Phoebe ends to the describe the problem. Then politely ask for a moment for you to answer your boss message and explain him that your answer delay was because you where attending a client.

Then start to work on solving the Phoebes problem.

1. Wait for Phoebe to end describe the problem.

2. Answer to the boss, explaining the situation.

3. Start solving Phoebes problem.

4 0
3 years ago
Other questions:
  • Write a script that will generate random integers in the range from
    10·1 answer
  • What device acts like a wireless base station in a network, acting as a bridge between wireless and wired networks?
    11·1 answer
  • What type of formatting does the clip below demonstrate
    6·1 answer
  • A mobile device user has tried to install a new app numerous times without success. She has closed all unused apps, disabled liv
    7·1 answer
  • Advantage of realtime processing​
    14·1 answer
  • A systems administrator is designing a directory architecture to support Linux servers using Lightweight Directory Access Protoc
    11·1 answer
  • What is booting as used in computers?​
    13·2 answers
  • It is common for people to name directories as dir1, dir2, and so on. When there are ten or more directories, the operating syst
    8·1 answer
  • Write an algorithm to find the area of a circle of radius r
    5·1 answer
  • *the sticker, available in the middle section of the prescription label, will indicate if the customer requested non-safety caps
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!