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
This network passes data most of the time, but sometimes for reasons unknown to the junior network engineer in charge of monitor
Kaylis [27]

Answer:

The characteristic that is violated is Availability.

Explanation:

  • The network is passing data at mostly, it means performance is good. Junior network engineer is doing his job well then there is minimum chance of network failure or lack of manageability.
  • The scalability; range of computing capabilties can be managed by the engineer.
  • However, sometimes the core router might get crashed due to unavailability of the network that is not under the control of the engineer.

8 0
4 years ago
Write an algorithm and draw flowchart to print 30 terms in the following sequence
valina [46]

Answer:

/*

I don't know what language you're using, so I'll write it in javascript which is usually legible enough.

*/

console.log(buildSequence(30));

function buildSequence(maxVal){

   maxVal = Math.abs(maxVal);

   var n, list = [];

   for(n = 1; n < maxVal; n++){

       /*

        to check for odd numbers, we only need to know if the last bit

        is a 1 or 0:

       */

       if(n & 1){ // <-- note the binary &, as opposed to the logical &&

           list[list.length] = n;

       }else{

           list[list.length] = -n;

       }

   }

   return list.implode(',');

}

3 0
3 years ago
If you must apply for a loan, you should _____. contact a broker and provide certain loan information visit a loan officer at a
azamat
B.) V<span>isit a loan officer at a financial institution and complete an application.</span>
4 0
3 years ago
Read 2 more answers
Which email attachments are generally safe to open
ycow [4]

Answer:

i would suggest not opening ones that start with bit . ly

Explanation:

pls mark brainliest

3 0
3 years ago
Read 2 more answers
Next, Adnan decides to recreate the structure on the
Lena [83]

Answer:

a square and a rectangle

Explanation:

8 0
4 years ago
Read 2 more answers
Other questions:
  • A network administrator is implementing dhcpv6 for the company. the administrator configures a router to send ra messages with m
    6·1 answer
  • I NEED HELP NOW PLEASE!!!!!!
    6·2 answers
  • Serveral cheetas are growling at each other while hunting for animals.for which need are they competing?
    14·1 answer
  • What does ADF means????
    13·2 answers
  • Buenas , ayudenme con esta tarea de excel 2016
    6·1 answer
  • What are 6 steps to take to figure out what's wrong with your computer?
    5·1 answer
  • The I/O modules take care of data movement between main memory and a particular device interface.A. TrueB. False
    9·1 answer
  • I need help someone plz i need it fast ..........
    7·2 answers
  • Create a Python program that computes the cost of carpeting a room. Your program should prompt the user for the width and length
    10·1 answer
  • Which of the following is an example of phishing attack? csp
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!