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
Kipish [7]
3 years ago
10

Take the average of some numbers. Show all the numbers that are below average. You can assume that there will not be more than 2

0 numbers entered. For example: Enter a weight (0 to stop): 1 Enter a weight (0 to stop): 2 Enter a weight (0 to stop): 3 Enter a weight (0 to stop): 4 Enter a weight (0 to stop): 5 Enter a weight (0 to stop): 6 Enter a weight (0 to stop): 7 Enter a weight (0 to stop): 8 Enter a weight (0 to stop): 9 Enter a weight (0 to stop): 10 Enter a weight (0 to stop): 0 The total was 55 The average is 5.5 Here are all the numbers less than the average: 1 2 3 4 5
Computers and Technology
1 answer:
olchik [2.2K]3 years ago
6 0

Here is code in java.

import java.util.*; // import package

class Main //  creating class

{

public static void main (String[] args) // main method

{

Scanner br=new Scanner(System.in); // scanner class for input

       int []a=new int[20]; // declaring array

       int count=0,x,j; // creating variable

       int sum =0;

       System.out.println("Enter a weight (0 to stop):");

       x=br.nextInt(); // taking input

while(x!=0) // iterating over the loop

       {

           a[count] = x;

           count++;

           System.out.println("Enter a weight (0 to stop):");

           x=br.nextInt();

}

       for( j=0;j<count;j++) // iterating over the loop

       {

       sum+=a[j];

       }

       double avg = sum/(double)count;

       System.out.println("The total is: "+sum);

       System.out.println("The average is: "+avg);

       System.out.println("Here are all the numbers less than the average: ");

     for( j=0;j<count;j++) //  // iterating over the loop

       {

           if(a[j]<avg)

           System.out.print(a[j]+" ");

       }

}

}

Explanation:

First create an object of "Scanner" class to read input from the user.

Create an array of size 20, which store the number given by user.Ask user

to give input and keep the count of number in the variable "count". If user

give input 0 then it will stop taking input.And then calculate sum of all the

input.It will calculate average by dividing the sum with count and print it.

It will compare the all elements of array with average value, if the element

is less than average, it will print that element.

Output:

Enter a weight (0 to stop):

1

Enter a weight (0 to stop):

2

Enter a weight (0 to stop):

3

Enter a weight (0 to stop):

4

Enter a weight (0 to stop):

5

Enter a weight (0 to stop):

6

Enter a weight (0 to stop):

7

Enter a weight (0 to stop):

8

Enter a weight (0 to stop):

9

Enter a weight (0 to stop):

10

Enter a weight (0 to stop):

0

The total is: 55

The average is: 5.5

Here are all the numbers less than the average:

1 2 3 4 5

You might be interested in
Please i need help here.. am giving brainliest.
Stels [109]

Answer:

1. High performance

The first and foremost characteristic of an expert system is to deliver high performance 24×7

2. Understandable

The expert system should be easy to comprehend for all the people using it.

3. Reliable

An expert system has to be reliable in the sense that it is error-free so that it is trustable.

4. Highly Responsive

An expert system has to be proactive and provide responses for each and every detail of the problem.

Explanation:

Description of each

and sorry if wrong, don't be mad

7 0
2 years ago
Read 2 more answers
John wants to know the amount of ram memory installed on his computer. in which category of the windows 7 control panel can this
Verizon [17]

John can find the amount of Random Access Memory (RAM) memory installed on his computer with the Windows 7 under the category “<u>System and Security</u>” in the Control Panel.

To know the total amount of installed RAM through Control Panel in the computer with Windows 7, John should follow the steps as:

  • Click the Windows key
  • Type Control Panel
  • Click the category named “System and Security”
  • Now under “System”, click “View amount of RAM and processor speed”
  • “Device Specifications” section displays the amount of installed RAM in John’s computer

Thus, above are the steps by which John’s can find the amount of installed RAM in his Windows 7 computer’s Control Panel.

What is Random Access Memory (RAM)?

RAM is the temporary memory in computers that stores the data currently being used by the processor.

You can learn more about Control Panel at

brainly.com/question/1445737

#SPJ4

5 0
1 year ago
Conceptos importantes de red de computadoras
Bumek [7]

Answer:

-Consiste en conectar varias redes de computadoras basadas en diferentes protocolos -Requiere la definición de un protocolo de interconexión común sobre los protocolos locales. -El Protocolo de Internet (IP) desempeña este papel, definiendo direcciones únicas para una red y una máquina host.

3 0
3 years ago
Assume inputFile is a Scanner object used to read data from a text file that contains a number of lines. Each line contains an a
anzhelika [568]

Answer:

words.hasNext()

Explanation:

Given the code snippet below:

  1.        while (inputFile.hasNextLine()) {
  2.            String word = "";
  3.            String line = inputFile.nextLine();
  4.            Scanner words = new Scanner(line);
  5.            while (words.hasNext()) {
  6.                word = words.next();
  7.            }
  8.            System.out.println(word); }
  9.    }

We have a inputFile Scanner object that can read data from a text file and we presume the inputFile has read several rows of data from the text file. So long as there is another line of input data available, the outer while loop will keep running. In each outer loop, one line of data will be read and assign to line variable (Line 3). Next, there is another Scanner object, words, which will take the current line of data as input. To get the last word of that line, we can use hasNext() method. This method will always return true if there is another tokens in its input. So the inner while loop will keep running so long as there is a token in current line of data and assign the current token to word variable. The word will hold the last token of current line of data upon exit from the inner loop. Then we can print the output (Line 8) which is the last word of the current line of data.

7 0
3 years ago
Which of the following statements best describes how digital photographs can be used?
kipiarov [429]

Answer:

umm wheres the options so we can answer it and ty

Explanation:

3 0
3 years ago
Read 2 more answers
Other questions:
  • True/False: If a function is legally prototyped to return an integer value, it can return a structure member that is an integer
    11·1 answer
  • Device that converts sound into electrical signals, which are sent to the computer or other recording device
    6·1 answer
  • Which protocol do many browsers assume when you enter a URL in the address field?
    9·1 answer
  • GUI allows users to communicate with a device and see what they are doing onscreen.
    9·1 answer
  • You have compiled a new kernel using rpm. when you reboot, the new kernel is not the default selection on the boot menu. you use
    10·1 answer
  • Define Class in C++. Briefly discuss.
    9·1 answer
  • What type of attacks take advantage of vulnerabilities in poorly coded web application software to introduce malicious program c
    9·1 answer
  • Write the definition of a function reverse, whose first parameter is an array of integers and whose second parameter is the numb
    15·1 answer
  • Assume there is a 30-byte heap. The free list for this heap has two elements on it. One entry describes the first 10-byte free s
    15·1 answer
  • Write a sub-program to display the acceleration of car. The program should ask initial velocity, final velocity, and time taken
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!