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
Please help me with these short questions &gt;..
Thepotemich [5.8K]

Answer:

bmjcmbbobnkpkkjkbk

Explanation:

vuvkopbbkvkhovjlplbkp

6 0
2 years ago
During the course of execution of a program, the processor will increment the contents of the instruction register (program coun
Oksana_A [137]
Bdbdbdhdhdhdhdjdbsbbrvrvrrvrvrvfvfvvfvfvfvfvfhdhdhdhdhdhdhhdududududududuebebbedvdvd I known why ahh it happened
8 0
2 years ago
Once jaden has decided upon the telecommunications technology his team will use, he will have completed the last step of the dec
mrs_skeptik [129]
<span>Once Jaden has decided upon the telecommunications technology his team will use, he will have completed the last step of the decision-making process. TRUE.</span>
6 0
3 years ago
What should you do if your temperature gauge moves up to just below the red zone?
Alexeev081 [22]
<span>If the temperature gauge moves up to just below the red zone,you should turn off your air conditioner and turn on your vehicle's heater. Then immediately </span>find a mechanic or pull over safely and contact a road service.




4 0
3 years ago
Read 2 more answers
Case Project 9-4: Troubleshoot an IP configurationYou work at a help desk and have just received a call from an employee who say
Svetllana [295]

Answer:

To get the IP address and other information on the workstation, type 'ipconfig' for windows or 'ifconfig' or Linux and press the return key.

The subnet mask is a class B type and 169.254.14.11 IP address shows that the workstation cannot access the DHCP server, so the IP address is not properly configured for network connection.

Explanation:

A computer network is an interconnection and intercommunication of two or more computer devices. All devices in a network must have an IP address, which can be static or dynamic from a DHCP server.

When a computer is configured to receive IP address from a DHCP server, but cannot reach the server, the IP address from the range of 169 is automatically assigned to it but still would not be able to communicate with other devices in the network.

4 0
2 years ago
Other questions:
  • Computer World sells laptops separately from accessory products like docking stations, anti-virus software, and external hard dr
    6·1 answer
  • In microsoft word, when you highlight existing text you want to replace you are
    10·1 answer
  • If a device does not require a driver, it is _____.
    6·1 answer
  • What do yo need to do for device manager to display nonpresent devices?
    9·1 answer
  • A researcher develops a new instrument to measure coping skills and conducts a pilot study to compare the new tool with an exist
    5·1 answer
  • What are 3 ways to select an entire document?
    15·1 answer
  • The Spanning Tree Protocol operates at the Network layer of the OSI model.
    13·1 answer
  • Write a program that keeps track of a simple inventory for a store. While there are still items left in the inventory, ask the u
    12·2 answers
  • Write a program that prompts the user to enter their name store this value in a variable called name Prompt the user for their c
    10·1 answer
  • The current in a resistor is 5.0 A, and its power is 60 W. What is the voltage?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!