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
Gnoma [55]
4 years ago
15

g 4.16 Write a program that takes any number of non-negative integers as input, and outputs the average and max. A negative inte

ger ends the input and is not included in the statistics. Ex: When the input is:
Computers and Technology
1 answer:
pashok25 [27]4 years ago
8 0

Answer:

import java.util.ArrayList;

import java.util.Scanner;

import java.util.Collections;

public class num4 {

   public static void main(String[] args) {

       int sum = 0;

       Scanner in = new Scanner(System.in);

       System.out.println("Enter number");

       int num = in.nextInt();

       ArrayList<Integer> list = new ArrayList<>();

       while (num >= 0){

       list.add(num);

       System.out.println("Enter another positive number, enter a negative to stop");

       num = in.nextInt();

       }

       int maximum = Collections.max(list);

       int listSize = list.size();

       for(int i:list){

           sum = sum+i;

       }

       double average = (double) sum/listSize;

       System.out.println("Maximum number entered is "+maximum);

       System.out.println("Average of the number is "+average);

   }

}

Explanation:

In this program:

  • A Scanner class is used to receive user input and store in a variable
  • A while loop with the condition while (num >= 0) is used to ensure only non-negative numbers are entered
  • An ArrayList is created and used to store all the user's valid entries
  • The Max Method in the Collections class is used to find the maximum value entered
  • To find the average, a for loop is used to add all elements in the list and divide by the size of the list
  • Finally the Average and maximum is printed out
You might be interested in
Where was this taken
Korolek [52]

Answer:

Mostar city

Explanation:

look at the architecture

6 0
3 years ago
Read 2 more answers
Which one of the following devices would you choose to meet those requirements?
tensa zangetsu [6.8K]
What are the requirements
5 0
2 years ago
Read 2 more answers
Enterprise information systems are also known as collaborative systems. true /false
ahrayia [7]

Enterprise information systems are also known as collaborative systems is a false statement.

<h3>What systems are also known as enterprise systems?</h3>

An enterprise system is known to be a term that is said to be also known as an enterprise resource planning (ERP) system.

Note this enterprise system is seen as a kind of a cross-functional information system that tends to give organization a form of larger scope as well as the coordination and the integration of some central business processes and aid them in the area of planning the resources of any given organization.

Note that Enterprise information systems are also known as collaborative systems is a false statement because it is an enterprise resource planning (ERP) system.

Learn more about Enterprise information systems from

brainly.com/question/14688347
#SPJ1

6 0
1 year ago
In what form do the hexadecimal numbers need to be converted for a computer’s digital circuit to process them?
MrMuchimi

Hexadecimal numbers are just a convenient representation of binary data. When entered as text, they consist of ASCII characters 0-9 and a-f. The numbers will then have to be converted to binary. This is accomplished by converting to uppercase, subtracting the ASCII offset (48 for 0-9 or 55 for A-F), so that the result is a number between 0 and 15 (inclusive). This can be stored in computer memory to represent 4 bits.

Hexadecimal numbers represent binary numbers in the following way:

hex | binary

0 = 0000

1 = 0001

2 = 0010

3 = 0011

4 = 0100

5 = 0101

6 = 0110

7 = 0111

8 = 1000

9 = 1001

a = 1010

b = 1011

c = 1100

d = 1101

e = 1110

f = 1111

As you can see, no other 4 bit combination exists.



5 0
4 years ago
Whatis Level of node ‘46’?
Ierofanga [76]

Answer:

6

Explanation:

The  tree is the hierarchical structure in the data structure, it has the properties like nodes, height, level etc.

the formula for calculating the maximum number of node at the given level.

number of nodes = 2^{l-1}

here, l is the level of node.

in the question the number of node is 46.

Substitute in the formula:

2^{l-1}=46\\ l-1=log_{2}46\\ l=5.5235+1\\l=6.6235

The Approx. value of level is 6

5 0
3 years ago
Other questions:
  • ____ errors occur when a formula is written incorrectly, when a mistake is made with a decision condition, or when the wrong var
    11·1 answer
  • Employers will check you out on social media sites like Facebook, MySpace, and Twitter.
    6·2 answers
  • Which of the following processes should angel use to merge cells a1:d4 to create a title
    15·1 answer
  • Most new information systems must communicate with other, existing systems, so the design of the method and details of these com
    9·1 answer
  • True or false This html element puts the text in the centre of the webpage. "Something really cool "
    14·1 answer
  • A 9-year old male castrated Westie presents on emergency after being rescued from a house fire. On presentation, the dog has a r
    9·1 answer
  • if anyone could help me with this it would be great. I have to turn in a practice resume and im completely lost and have no clue
    7·1 answer
  • What is humanity’s greatest invention?
    13·1 answer
  • Can someone help on number 8? Plz
    14·1 answer
  • This feature allows you to adjust your view to see the lower and upper part of a document
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!