Competitions
PP2. Week 7: April 19 - 25
Java Abstract Array Sum Average
Implement abstract class Arr.
Implement class Array that extends Arr.
abstract class Arr
{
int a[]; // array of integers
int n; // size of array
abstract int Sum(); // Return sum of array elements
abstract double Average(); // Return average of array elements
}
class Array extends Arr
{
Array (int n) // Constructor
int Sum() // Return sum of array elements
double Average() // Return average of array elements
}
Input
First line contains number n. Next line contains n integers in the range from 0 to 100.
Output
Print in one line the sum of array elements and their average.
Input example #1
5 3 6 8 2 4
Output example #1
23 4.6