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
Before creating a brief to design a product, what is needed
castortr0y [4]

Answer:

A good design brief often begins with some information about the client and what their brand stands for. Including this helps to connect an individual project with the bigger picture. Aim to capture key points about what the company does, how big they are, and what their key products or services are.

Explanation:

A good design brief often begins with some information about the client and what their brand stands for. Including this helps to connect an individual project with the bigger picture. Aim to capture key points about what the company does, how big they are, and what their key products or services are.

8 0
3 years ago
For the Address Block 195.200.0.0/16 a. If you have 320 Customers that need 128 addresses/customer - will there be enough addres
Shkiper50 [21]

Answer / Explanation:

195.200.0.0/16

Note: Class C address can not be assigned a subnet mask of /16 because class c address has 24 bits assigned for network part.

2ⁿ = number of subnets

where n is additional bits borrowed from the host portion.

2ˣ - 2 = number of hosts

where x represent bits for the host portion.

Assuming we have 195.200.0.0/25

In the last octet, we have one bit for the network

number of subnets  = 2¹  =2 network addresses  

number of host = 2⁷ - 2= 126 network addresses per subnets

8 0
3 years ago
What are the limits of hashing and verifying that files haven’t changed?
earnstyle [38]

The hashing function can take any number of key-value pairs and there is no specific limit to it.

<h3>What is hashing?</h3>

Hashing is a file-based algorithm for producing a fixed-length bit string value. A file is essentially a collection of data blocks. The length of the data is reduced by hashing to a fixed number or key that represents the original string.

When hashing is employed, the hash function may plot all of the keys and values to what the real size of the table is, demonstrating that the hashing function can take any number of key-value pairs with no restriction.

However, if the passwords are hashed in encryption, recovering the passwords is extremely difficult.

Thus, the hashing function can take any number of key-value pairs and there is no specific limit to it.

Learn more about the hashing here:

brainly.com/question/13106914

#SPJ1

5 0
1 year ago
Which line of code will only allow a symbol to be stored in a variable?
nataly862011 [7]
<h2>Answer:</h2><h2></h2><h2>phone = int(input("What is your phone number?"))</h2><h2></h2><h2>Hope this helps, have a great day, stay safe, and positive!!</h2>

8 0
2 years ago
Read 2 more answers
Elizabeth has an assignment to complete. in her internet search, she got 5,006,321 hits. to narrow the search, she would convert
ivolga24 [154]
In order to narrow the search and get more precise and more efficient Internet research, Elizabeth should use unique and specific terms, should not use common words, she could use some search engines also (Exploratium, Teoma,...) ..., use different search engines search engines, like Yahoo!, Bing, Startpage, or Lycos.
6 0
2 years ago
Read 2 more answers
Other questions:
  • How to do this? ICT Excel there's a screenshot attached
    6·1 answer
  • What is the name of the advanced warrior race of robots in Doctor Who?
    10·2 answers
  • Could I use a prepaid card to buy a Brainly membership because I tried to get the trial with a low balance but more than like 5$
    11·1 answer
  • 9.
    15·1 answer
  • An EULA usually takes the form of an electronic notification that appears when installing software. The user then has a choice t
    14·1 answer
  • B. What significant values have you learned while learning the tools and utensils?
    8·1 answer
  • What is digital marketing?
    5·1 answer
  • Brainliest to right answer.
    10·1 answer
  • Database queries is an example of
    14·1 answer
  • You find a picture of a famous department store online that would be great to include in a project of yours. What should you do
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!