Westonci.ca is the ultimate Q&A platform, offering detailed and reliable answers from a knowledgeable community. Explore a wealth of knowledge from professionals across different disciplines on our comprehensive platform. Get detailed and accurate answers to your questions from a dedicated community of experts on our Q&A platform.
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 this was helpful. Please come back whenever you need more information or answers to your queries. Thank you for visiting. Our goal is to provide the most accurate answers for all your informational needs. Come back soon. We're here to help at Westonci.ca. Keep visiting for the best answers to your questions.