import java.util.Scanner;

/**
 * say how daily temps differed from a week's average
 *
 * @author Mark Young (A00000000)
 */
public class UsingAnArray {

    /**
     * Run this program.
     *
     * @param args command lines arguments (ignored)
     */
    public static void main(String[] args) {
        // introduce self
        System.out.println("\n"
            + "This program reads in a week's worth of daily highs "
            + "and prints out\nhow they differ from the average.\n");

        // create variables
        Scanner kbd = new Scanner(System.in);
        double[] temps = new double[7];
        double sum = 0.0;
        double ave;

        // read and sum the temperatures
        System.out.println("Enter " + temps.length 
            + " daily high temperatures below:");
        for (int i = 0; i < temps.length; i++) {
            temps[i] = kbd.nextDouble();    // read temp
            sum += temps[i];            // add it to sum
        }
        kbd.nextLine();     // tidy up input stream

        // calculate the average
        ave = sum / temps.length;

        // print the temps along with their difference from the average
        System.out.print("\nDay\tHigh\tDifference");
        System.out.print("\n---\t----\t----------\n");
        for (int i = 0; i < temps.length; i++) {
            System.out.println(i + "\t" + temps[i] + "\t" + (temps[i] - ave));
        }
        System.out.println();

    }

}
