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.
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);
}
We hope you found this helpful. Feel free to come back anytime for more accurate answers and updated information. We appreciate your time. Please come back anytime for the latest information and answers to your questions. Thank you for visiting Westonci.ca, your go-to source for reliable answers. Come back soon for more expert insights.