Respuesta :
Answer:
import java.util.Arrays;
import java.util.Scanner;
public class TestClock {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("How many numbers are you dealing with");
int numList = in.nextInt();
int []numArray = new int[numList];
for (int i=0; i<numArray.length; i++){
System.out.println("Enter the values");
numArray[i]= in.nextInt();
}
//Finding average
int sum =0;
for(int i=0; i<numArray.length; i++){
sum = sum+numArray[i];
}
int average = sum/numList;
//Finding the maximum
int max = numArray[0];
for(int i =0; i<numArray.length; i++){
if(numArray[i]>max){
max = numArray[i];
}
}
System.out.println(Arrays.toString(numArray));
System.out.println(max+" "+average);
}
}
Explanation:
- Create an array to hold the values to be entered by the user
- Using a for statement sum up the elements of the array and find their average
- Using another for loop find the maximum value in the array
- Output the array
- Output the maximum and average
Answer:
Python
nums = [int (i) for i in input().split()]
max_sorted = sorted(nums)
avg = sum(nums) // len(nums)
print(avg, max_sorted [-1])
Explanation:
First you want input and to split it. so they can add numbers like this 12 13 15 16
Then you sort it which will sort the list so that the greatest value is at the end.
you define average as avg
Finally you print the average and the end of the sorted list which will be the max value!