import java.util.*;

public class AverageGasPrice
{
	public static void main(String[] args)
	{
		double[] gasPrice = new double[25];
		int priceCount = 0;
		double price = 0;

		Scanner keyboard = new Scanner(System.in);
		System.out.println("This program calculates and displays the average");
		System.out.println("price of a regular gallon of gas.");

		System.out.println("Enter the price of gas or -99 to Quit: ");
		price = keyboard.nextDouble();

		while(price != -99)
		{
			gasPrice[priceCount] = price;
			priceCount++;
			price = keyboard.nextDouble();
		}

		//Compute the average
		double sum = 0;

		for(int i=0; i < priceCount; i++)
		{
			sum = sum + gasPrice[i];
		}

		double average = sum/priceCount;

		System.out.print("\n\nThe average price per gallon of regular");
		System.out.println(" gas is " + average);

	}
}