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
Which option identifies what the computer will yield in the following scenario?
dolphi86 [110]
I think it would be the computer program will create a design with the exact dimensions
6 0
2 years ago
So I emailed Brainly to deleted my account. Why haven’t they done so yet? I don’t want to get charged money for this app I was p
joja [24]

Answer:

Go to the Use the profile settings page. Click on "I want to delete my account" button located inside the Privacy tab on your profile settings page. Enter your Password.

Explanation:

8 0
3 years ago
What is an occupation?​
LiRa [457]

Answer:

a job or profession.

4 0
3 years ago
3 thing I learned in ICT
frutty [35]
I’ve learned makes me understand how it is important in our life to have an internet, and also important to know as a things I’ve known. First of all, I have learned about Camtasia, it is a program that are used to make a video about. And to show the others that how to do this or that on the computer.
6 0
3 years ago
What is a music composition copyright?
Anestetic [448]
For copyright<span> purposes, there is a difference between </span>MUSICAL<span> COMPOSITIONS and SOUND RECORDINGS. A </span>Musical Composition<span> consists of </span>music<span>, including any accompanying words, and is normally registered as a work of performing arts. The author of a </span>musical composition<span> is generally the composer and the lyricist, if any.</span>
3 0
2 years ago
Read 2 more answers
Other questions:
  • What do the letters of the su command stand for? what can you do with su besides give yourself root privileges? "what can you do
    5·1 answer
  • Please help me with these questions
    5·1 answer
  • Technology is often discovered by accident
    5·1 answer
  • Josh wants to convey his best wishes to johnathin for a meeting schedualed later diring the day. Which business documented would
    7·1 answer
  • Arrange the binary number in increasing order of their arithmetic output in the decimal number system ?
    9·1 answer
  • Resumen sobre Tailandia​
    10·1 answer
  • 5.7 AP-Style MC Practice edhessive
    14·1 answer
  • Which keyboard shortcut cuts information to the clipboard?
    14·1 answer
  • Fill in the blank
    13·1 answer
  • Roles of computer in business areas​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!