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
Lime is using social media to ask consumers about the qualities they desire in an electric scooter. The firm hopes to develop a
tresset_1 [31]

Answer:

The correct answer to the following question will be "Product".

Explanation:

  • Product marketing is often a mechanism by which a brand is marketed and delivered to a client. It's also known as the intermediate feature between product innovation and brand recognition or awareness.
  • It's something to which comparison is made when selling a product on the market to the consumer.

Therefore, the Product is the right answer for the above question.

8 0
3 years ago
Contrast the following terms (provide examples): Partial dependency; transitive dependency
kiruha [24]

Answer:

Explanation:

Transitive dependency

In this case, we have three fields, where field 2 depends on field 1, and field three depends on field 2.

For example:

Date of birth --> age --> vote

Partial dependency

It is a partial functional dependency if the removal of any attribute Y from X, and the dependency always is valid

For example:

Course and student these tables have a partial dependency, but if we have the field registration date, this date will depend on the course and student completely, we must create another table with the field registration date to remove this complete dependency.

If we remove or update the table registration date, neither course nor student must not change.

5 0
2 years ago
. If you executean infinite recursive function on a computer it will executeforever.
S_A_V [24]

Answer:

b. False

Explanation:

If you execute an infinite recursive function on a computer it will NOT execute forever.

4 0
2 years ago
The battery indicator light is on, even though your laptop is plugged into the AC adaptor. To determine why you are not getting
Natasha2012 [34]

Answer:

D. All of the above

Explanation:

When the laptop of the battery is low it shows a red light specifies that the battery of the laptop is low but the laptop charger is plugged into the Ac adapter still the power is not getting from the Ac adapter so we should check whether the AC adapter is properly connected to the laptop or not,  whether the ac adapter is plugged to a live electric outlet or not or whether the DC jack is loose or not.

In overall, we have to check all the given conditions mentioned in the question

6 0
2 years ago
Read 2 more answers
What is an RGB value?
jasenka [17]
Color's RGB value indicates its red, green, and blue intensity. Each intensity value is on a scale of 0 to 255, or in hexadecimal from 00 to FF.

RGB values are used in HTML, XHTML, CSS, and other web standards. For more, including visual samples and RGB values, see:
5 0
3 years ago
Other questions:
  • Remember that the function "main" takes optional parameters, these being common:
    10·1 answer
  • When one block is executed after another block in order from top to bottom, this is called ______ (see picture) Question 31 opti
    8·1 answer
  • 9. The best way to insert an existing Excel chart into a document is to A. use the Object command. B. click the Insert tab and c
    6·2 answers
  • In codd's model of a relational database, data is stored in a(n) _____, which maintains information about a(
    7·1 answer
  • If anybody knows what does this mean I will answer any questions for you and plz answer this right plz what does that envelope w
    5·2 answers
  • Computer design replaced ______________
    14·1 answer
  • A computer is unable to access the network. when you check the led lights near the computer's network port, you discover the lig
    6·1 answer
  • What is one purpose of an essay’s conclusion paragraph?
    13·1 answer
  • Ranboo back story? (not homework i just wanna find some ppl who are interested in the same things) ft. the reddie meme
    9·2 answers
  • Anyone have any website ideas I could use for my computing website project? Thank you.
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!