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
Aleks [24]
4 years ago
12

g Statistics are often calculated with varying amounts of input data. Write a program that takes any number of non-negative inte

gers as input, and outputs the average and max. A negative integer ends the input and is not included in the statistics. Ex: When the input is:
Computers and Technology
1 answer:
AnnZ [28]4 years ago
6 0

Answer:

import java.util.Scanner;

public class LabProgram

{

  public static void main(String[] args) {

  Scanner sc = new Scanner(System.in);//to read input

  int count=0;//to keep track of the count of numbers entered

  int max=0;//to store the maximum value

  int sum=0;//to store the sum of numbers entered

  double av=0;//to calculate and store the average

  //reading inputs until a negative number is entered

  while(true)

  {

  int n = sc.nextInt();//reading input

  if(n<0)//if negative number

  break;//then stopping loop

  count++;//increasing count

  if(count==1)//means it is first number

  max=n;

  else if(max<n)//if current number is greater than previous max

  max=n;//updating max

  sum+=n;//adding new number to sum

  }

  //finding average

  av = (double)sum/count;

  //displaying output

      System.out.println((int)av+" "+max);//remove type casting (int) here, if you want decimal places also

  }

}

You might be interested in
What is indirect recursion?
marshall27 [118]
Most basic examples of recursion, and most of the examples presented here, demonstrate direct recursion, in which a function calls itself. Indirect recursion occurs when a function is called not by itself but by another function that it called (either directly or indirectly). For example, if f calls f, that is direct recursion, but if f calls g which calls f, then that is indirect recursion of f. Chains of three or more functions are possible; for example, function 1 calls function 2, function 2 calls function 3, and function 3 calls function 1 again.

Indirect recursion is also called mutual recursion, which is a more symmetric term, though this is simply a difference of emphasis, not a different notion. That is, if f calls g and then g calls f, which in turn calls g again, from the point of view of f alone, f is indirectly recursing, while from the point of view of g alone, it is indirectly recursing, while from the point of view of both, f and g are mutually recursing on each other. Similarly a set of three or more functions that call each other can be called a set of mutually recursive functions.
3 0
3 years ago
Five corporations own over 90 percent of the media in the US.<br> 1.True<br> 2.False
avanturin [10]
<span>Five corporations own over 90 percent of the media in the US : </span>1.True.

7 0
4 years ago
An I/O-bound process ___________________________________________________ Select one: a. does not need CPU time b. spends less of
DiKsa [7]

Answer:

Spends more of its time seeking I/O operations than doing computational work.

Explanation:

The I/O bound process are depend on Input and output speed. on the other hand computational work is associated with CPU bound processes. Therefore option "C" is better option for I/O bound processes.

8 0
4 years ago
Suppose h(m) is a collision-resistant hash function that maps a message of arbitrary bit length into an n-bit hash value. is it
Korolek [52]

That can't be true. Collision resistant just means the chance is really low, but not 0. Suppose you enumerate all possible hash values with each their different original message. Since the message length can be larger than n, you can then find a message whose hash is already in the list, ie., a collision!

5 0
3 years ago
Lord Strawberry, a nobleman, collected birds. He had the finest aviary in Europe, so large that eagles did not find it uncomfort
creativ13 [48]

Answer:

That was a very great story that I totally did NOT read cause it too long 0-0.

Explanation:

To my ferns.....GET ON RN CAUSE I WONLEY T^T

Anyways wuv c'alls and have a good day :3

8 0
3 years ago
Other questions:
  • Why is there more content on youtube in 4k then there is on cable, satellite, and digital tv combined?
    6·2 answers
  • Using ______, a smartphone can connect to an automobile audio/control system
    6·1 answer
  • Define function print_popcorn_time() with parameter bag_ounces. If bag_ounces is less than 3, print "Too small". If greater than
    14·2 answers
  • There are _______ pints are in 8 cups.
    10·2 answers
  • What is the difference between word processing software and email?
    12·2 answers
  • Fill in the blank with the correct response.
    10·1 answer
  • Create a script that prompts for the user to input a directory and then prints out the number of sub-directories in the given di
    14·1 answer
  • Write a python program to print numbers from 100 to 50 using for loop.<br> I NEED THIS URGENT PLEASE
    9·1 answer
  • Write an algorithm to sum all numbers between 0 and 1000 that are divisible by ,7​
    8·1 answer
  • How many binary digits are in 10^100.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!