// Guide to Data Structures
// Section 1.6
// Copyright 2018, by J.T. Streib and T. Soma

import java.util.*;
public class TestScores {
public static void main(String[] args) {

scores = new Scores();
scores.enterScores();
scores.computeAverage();

scores = new Scores1D();
scores.enterScores();
scores.computeAverage();
}
}

// asks user to enter test scores
public void enterScores();

// computes and outputs average of test scores
public void computeAverage();

}

import java.util.*;
public class Scores implements ScoresAvgADT {
private final static int NUM_EXAMS = 3;
private Scanner scanner = new Scanner(System.in);
private int exam1,exam2,exam3;

public Scores() {
}

public void enterScores() {
System.out.print("Enter three scores: ");
exam1 = scanner.nextInt();
exam2 = scanner.nextInt();
exam3 = scanner.nextInt();
}

public void computeAverage() {
double sum;
sum = exam1 + exam2 + exam3;
System.out.printf("Average score: %.2f \n",
sum / NUM_EXAMS);
}
}

import java.util.*;
public class Scores1D implements ScoresAvgADT {
private final static int NUM_EXAMS = 3;
private Scanner scanner = new Scanner(System.in);
private int[] exam;

public Scores1D() {
exam = new int[NUM_EXAMS];
}

public void enterScores() {
System.out.print("Enter three scores: ");
for(int i=0; i<NUM_EXAMS; i++)
exam[i] = scanner.nextInt();
}

public void computeAverage() {
double sum;
sum = 0.0;
for(int i=0; i<NUM_EXAMS; i++)
sum = sum + exam[i];
System.out.printf("Average score: %.2f \n",
sum / NUM_EXAMS);
}
}