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
Mathematics and computer science share many concepts.
Nastasia [14]

Answer:

Recursion

Explanation:

7 0
3 years ago
Read 2 more answers
What does the computer receive when you press a key on a laptop keyboard?
Anit [1.1K]

Answer:

a computer receives signal

6 0
3 years ago
Which property of a DBMS lets you change the database structure without requiring you to change the programs that access the dat
Gala2k [10]

Answer:

"Integrity constraints " is the correct answer.

Explanation:

  • A successful DBMS offers integrity constraints, which have been an option that allows you to modify the database layout without modifying the applications accessing the repository.
  • A principle or requirement which the data in something like a database should therefore obey.

So that the above is the correct choice.

8 0
4 years ago
Cyber vulnerabilities to dod systems may include
Ivan

Cyber vulnerabilities to dod systems may include all of the above Options.

<h3>What is Cyber vulnerabilities?</h3>

In cybersecurity, a vulnerability is known to be any kind of weakness  exist with the aim to be exploited by cybercriminals to be able to have unauthorized access to a computer system.

Note that in the case above, Cyber vulnerabilities to dod systems may include All of the above Options.

Learn more about cyber vulnerabilities from

brainly.com/question/7065536

#SPJ11

6 0
2 years ago
if you upgrade your memory but notice the RAM count does not reflect the additional memory, what should you do ?
alisha [4.7K]

Try looking at your motherboard manual to see which dimm slots should be used first since putting memory in any slot could break the dual channel. Not giving your motherboard access to that ram. Or you probably used wrong memory since your memory has to be the exact same size and speed and type. Because 8gb ddr3 will not work with 8gb ddr4. 8gb ddr4 2400 MHz will also not work with 8gb ddr4 3200 MHz. And 8gb 3200 Mhz would not work with 16Gb 3200 mhz. Your ram should have the exact same specs.

3 0
4 years ago
Other questions:
  • ( answer goes here) are pictures that you can click on to tell your computer what to do.
    10·2 answers
  • A ________ editor was the dominant way film was edited up until the early '90s.
    7·2 answers
  • What is created for each user the first time the user logs onto windows?
    7·1 answer
  • ____ errors occur when a formula is written incorrectly, when a mistake is made with a decision condition, or when the wrong var
    11·1 answer
  • If I gain a rank and go under the points that the rank coust do I lose the rank
    8·2 answers
  • Powerpoint s _____ feature allows you to set the timing for a video clip
    12·1 answer
  • A spreadsheet has some values entered: Cell A1 contains 10, cell A2 contains 14, A3 contains 7. You enter in cell A4 the followi
    8·1 answer
  • Zack is taking a survey that contains questions about his future plans. Which question would most likely be on the survey?
    9·2 answers
  • In a penetration test, a ________ team consists of IT staff who defend against the penetration testers. They are generally aware
    14·1 answer
  • Consider the following method:
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!