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
Ganezh [65]
4 years ago
8

Write a program that computes the average of a list of numbers entered by the user. The numbers are supposed to be in the range

50 – 100 (inclusive) and the user will indicate that he/she is done with data input by entering a value not in that range. At least one number will be in the range. Use a WHILE or a DO-WHILE loop.
Computers and Technology
1 answer:
Maru [420]4 years ago
8 0

Answer:

The answer to this question can be given as:

Program:

//import package.

import java.util.*;  

public class Main      //define the main class.

{

public static void main(String[] ar) //define main method.

{    

    int sum=0,avg=0,count=0,data;  //define varaible

    // Create a Scanner class object.    

    Scanner ob1 = new Scanner(System.in);  

    System.out.println( "enter number between 50 - 100 After done please insert 0:"); //message

    data = ob1.nextInt();  //input by user.  

    while (data >50 && data<100)   //number between 50 to 100

    {

        if(data!=0)  //condition

        {

            sum =sum+ data;        //add numbers.    

            data = ob1.nextInt();   //next input

            count++;  //count number.

        }

    }      

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

    avg=sum/count;

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

}

}

Output:

enter number between 50 - 100 After done please insert 0:

80  

89

90

96

66

89

0

The sum is :510

The average is :85

Explanation:

In the above program firstly we import java util package. This package is used to take input from the user. Then we declare the class that is main in this class we define the main function in the main function we define the variable that is sum, avg, count, and data. In the data variable, we take the input from the user. Then we define the while loop in this loop we define condition that number is greater then 50 and less than 100.in this loop we define if block in the if block we check that the number is not equal to 0. so it will sum all the elements and count the number inserted by the user. In the last, it will print the sum of the number and the average of the number.

You might be interested in
How to get flash to work on chrome?
timofeeve [1]

Answer:

Open Chrome on your computer. If you’re using Windows, you’ll usually find it in the Start menu.

Click the ⁝ menu.

Click Settings.

Scroll down and click Advanced.

Scroll down and click Content settings.

Explanation:

5 0
2 years ago
Boolean, integer, string, and float are examples of:
bulgar [2K]

Answer:

variables

Explanation:

8 0
3 years ago
Read 2 more answers
897,100 rounded to the nearest hundred thousand is
dmitriy555 [2]

The answer would be 900,100 because the hundred thousand is the 8 and since the number next to the 8 is a nine, the 8 is rounded up

7 0
3 years ago
What is the awnser ?
Igoryamba

Its the second one. Hope this helps.   :)

4 0
4 years ago
Please help me I am crying because I don't know
saw5 [17]

Answer:ubers texi’s

Explanation:

3 0
3 years ago
Other questions:
  • If you want a user to enter exactly 20 values which loop would be the best to use
    12·1 answer
  • If someone receives a shock, or a piece of equipment is throwing sparks or arcing you should try to pull them away from the sour
    7·1 answer
  • 9) If you are working on the part of 5-15 minutes, time-stamping (every 30 seconds) should start at: a) [00:05:00] b) [00:00:00]
    9·1 answer
  • When executing System.out.println(a2), the toString() method in the Object class is invoked. The program cannot be compiled, bec
    11·1 answer
  • A firm can survive and succeed in the long run if it successfully develops strategies to confront the _______________ that shape
    9·1 answer
  • Mention 5 advantages of internet​
    8·1 answer
  • This is your code.
    9·1 answer
  • Which clue can be used to identify a chemical reaction as a combustion reaction?
    9·1 answer
  • What number is represented as a binary code of 101110
    5·2 answers
  • 1. A cell is identified by its ........
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!