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
Which examples demonstrate common education and qualifications for Manufacturing Production Process Development careers? Check a
Tom [10]

Answer:

The answer is D "Latisha is a Mechanical Engineer with a bachelor's degree"

Explanation:

Workers in Manufacturing Production Process Development are liable for designing plan and plan of the manufacturing process. They work with clients to guarantee the manufacturing process delivers an item that meets or surpasses client expectations. Manufacturing Production Process Development is one of the many career paths in the Manufacturing Industry. Laborers in this Profession Way are liable for fundamental item plans and the plan of the manufacturing process itself. They should reliably draw in with their client to guarantee they produce an item that precisely coordinates their client's necessities. Occupations in this Profession Way incorporate Electrical and Electronic Drafters, Modern Designing Technologists, Assembling Creation Professionals, and Atomic Checking Specialists.

3 0
3 years ago
Read 2 more answers
Hordes of surreptitiously infiltrated computers, linked and controlled remotely, also known as zombie networks are known as:
icang [17]
~Hello there! ^_^

Your answer: Hordes of surreptitiously infiltrated computers, linked and controlled remotely, also known as zombie networks are known as..?

Your answer: Hordes of surreptitiously infiltrated computers, linked and controlled remotely, also known as zombie networks are known as botnets.

Hope this helps~





3 0
4 years ago
What are some of the challenges that could arise from setting up a file management system on a computer?
erastovalidia [21]
One challenge is that arranging things in simple folders creates a limited structure that obstructs the way that would perfectly suit your needs. Any information that is dependent on those folders can easily get lost by removing as much as a simple image from that folder, in the events that the information is dependent on the folder structure.
7 0
3 years ago
You are !o code and execute a C program to input narnes ard addresses t]rat are in alphabctic order and output the names and add
alexgriva [62]

Answer:

#define MAX 50

#include <stdlib.h>

#include <stdio.h>

#include <string.h>

struct address

{

char name[MAX];

char street[MAX];

char city[MAX];

char zip[10];

};

void in(struct address *, int *);

void sort(struct address *, int);

void out(struct address *, int);

int main(){

struct address *ADDRESS = (struct address *)malloc(50*sizeof(struct address));

int n=0;

in(ADDRESS, &n);

sort(ADDRESS, n);

out(ADDRESS, n);

}

void in(struct address *ADDRESS, int *num)

{

FILE *fp;

char fname[MAX];

printf("Enter input file name: ");

scanf("%s", fname);

fp = fopen(fname, "r");

if (fp == NULL)

{

printf("Unable to open file");

exit(1);

}

int a = 0;

while (!feof(fp))

{

//ADDRESS = (struct address *)realloc(ADDRESS, (a + 1) * sizeof(struct address));

if(a>=50)

break;

fscanf(fp, "\n%[^\n]s", (ADDRESS+a)->name);

fscanf(fp, "\n%[^\n]s", (ADDRESS+a)->street);

fscanf(fp, "\n%[^\n]s", (ADDRESS+a)->city);

fscanf(fp, "\n%[^\n]s", (ADDRESS+a)->zip);

a++;

}

printf("Successfully %d read from file\n", a);

*num = a;

}

void sort(struct address *ADDRESS, int num){

int i, j;

for(i=0; i<num; i++){

for(j=i+1; j<num;j++){

if(strcmp((ADDRESS+i)->zip, (ADDRESS+j)->zip)>0){

struct address t = *(ADDRESS+i);

*(ADDRESS+i) = *(ADDRESS+j);

*(ADDRESS+j) = t;

}

}

}

}

void out(struct address *ADDRESS, int num)

{

FILE *fp;

char fname[MAX];

printf("Enter output file name: ");

scanf("%s", fname);

fp = fopen(fname, "w");

if (fp == NULL)

{

printf("Unable to open file");

exit(1);

}

int a;

for(a=0; a<num; a++)

{

fprintf(fp, "%s\n", (ADDRESS+a)->name);

fprintf(fp, "%s\n", (ADDRESS+a)->street);

fprintf(fp, "%s\n", (ADDRESS+a)->city);

fprintf(fp, "%s\n", (ADDRESS+a)->zip);  

}

printf("Successfully %d Write to file\n", a);

fclose(fp);

}

Explanation:

4 0
3 years ago
What are the 6 external parts of a computer
Sedbober [7]

External computer components connect to the motherboard through a series of ports on the computer case. Many components have their own dedicated port connections, such as those to connect audio equipment or the computer monitor. Others may share a single type of connector, such as the USB, that connects everything from keyboards and mice to game pads and external hard drives. there


8 0
4 years ago
Other questions:
  • What's usually kept in database?
    7·2 answers
  • Which is the highest level of the hierarchy of needs model?
    5·2 answers
  • You have a network that uses a logical ring topology. how do messages travel through the network"
    10·1 answer
  • How long would it take a 8 bit computer to calculate π to the thousandth place?
    8·1 answer
  • Which line defines a valid CSS rule?
    6·2 answers
  • Marly is using her smartphone to review a webpage that she created. The formatting and alignment of webpage elements is incorrec
    11·1 answer
  • Study the original and changed passages.
    8·2 answers
  • What is the name for the last word on a dictionary page?
    13·1 answer
  • QUICK HELP ME PLEASE
    9·1 answer
  • Kevin, a manager at FitPlus fitness club, owns a website that updates information regarding his fitness club. He created backgro
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!