Looking for answers? Westonci.ca is your go-to Q&A platform, offering quick, trustworthy responses from a community of experts. Get immediate and reliable answers to your questions from a community of experienced professionals on our platform. Our platform provides a seamless experience for finding reliable answers from a network of experienced professionals.

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);

               }