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.
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 hope you found what you were looking for. Feel free to revisit us for more answers and updated information. We're here to help at Westonci.ca. Keep visiting for the best answers to your questions.