Discover answers to your questions with Westonci.ca, the leading Q&A platform that connects you with knowledgeable experts. Get quick and reliable solutions to your questions from a community of experienced professionals on our platform. Connect with a community of professionals ready to help you find accurate solutions to your questions quickly and efficiently.

Statistics are often calculated with varying amounts of input data. Write a program that takes any number of non-negative integers as input, and outpu

Sagot :

Answer:

Explanation:

The following program is written in Java and is a function that asks the user for an input and keeps doing so until a negative value is entered, in which case it calculates the average and max values and prints it to the screen.

public static void average () {

                       int num;

                       int sum = 0;

                       Scanner in = new Scanner(System.in);

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

                       num = in.nextInt();

                       int count = 0;

                       int max = 0;

                       while(num >= 0)

                       {

                               sum+=num;

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

                               num = in.nextInt();

                               count++;

                               if(num>=max){

                                       max = num;

                               }

                       }

               System.out.println(sum/count);

               System.out.println(max);

               }