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
Most case fans have standard _______________ connectors that are easy to plug in but can be forced to be connected the wrong way
SIZIF [17.4K]

Answer:

Molex

Hope this Helps!

4 0
2 years ago
Có n chiếc kẹo và m em bé. Hãy viết chương trình nhập vào hai số nguyên dương n, m và kiểm tra n chiếc kẹo có chia đều được cho
sleet_krkn [62]

uy ako ba yung pilipino dito hi nga kau

5 0
2 years ago
How are switches indirectly involved in ARP poisoning?
11Alexandr11 [23.1K]

Answer:

They

are indirectly involved in the attack because they do not verify the the MAC/IP address

association

Explanation:

PLEASE MARK ME AS BRAINLIEST

8 0
3 years ago
I WILL GIVE BRANLIST
qaws [65]

Answer:

space alignment

Explanation:

I'm not sure just taking a guess cuz I'm bored lol

4 0
2 years ago
Read 2 more answers
What statement should you use to print the value of total with a precision of 5 digits?
Norma-Jean [14]

Answer:

Option A: print("The total is %0.5f" % total)

Explanation:

To ensure the value is rounded to a precision of 5 digits, we have to create a formatted string which is %0.5f. The <em>.5</em> denotes five decimal places and <em>f </em>refers to float data type.

Next, we use the <em>%</em> operator again and followed with the variable <em>total</em>. The % is used as a string modulo operator that will interpolate the value held by the the variable <em>total </em>in the formatted string that we create previously. The interpolated value will be rounded to 5 decimal places. For example, if

total = 256.786789

The output will be 256.78679

5 0
3 years ago
Other questions:
  • Tower defense is included under which genre of game
    15·2 answers
  • What are the most popular/up-and-coming social media applications?
    10·2 answers
  • Which kind of software allows users to draw pictures, shapes, and other graphical images with various on-screen tools such as a
    14·1 answer
  • Mary is entering her senior year of college. She has a meeting on Friday with her advisor to discuss her career plans.Mary is al
    15·1 answer
  • Create a class 'ProblemSolution' with following characteristics A public method 'solution' without parameters and return type is
    14·1 answer
  • What does ctto mean?
    11·2 answers
  • Cuantos MB son 8,192 kb?​
    13·1 answer
  • NumA = 3 <br>numB = 2<br>Result = numA ** numB
    12·1 answer
  • Please help me willgive u brainliest​
    14·1 answer
  • Write a C# program named ProjectedRaises that includes a named constant representing next year’s anticipated 4 percent raise for
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!