/*George Cheng
Lab 1
9/27/2013
*/
import java.util.Scanner;
public class lab_1
{
public static void main(String args[])
{
Scanner scan = new Scanner(System.in);
boolean isInteger = true;
float first = 0;
float number = 0;
float[] high = new float[2];
float[] low = new float[2];
float count = 0;
float sum = 0;
System.out.println(“Welcome.\nInput a non-numerical character to quit at any time.”);
do
{
System.out.println(“\nEnter a number: “);
isInteger = scan.hasNextFloat();
if(!isInteger)
{
System.out.println(” “);
continue;
}
number = scan.nextFloat();
sum += number;
count++;
if(count == 1) // this represents the first number that you have entered
{
first = number;
}
if(number >= high[0] || (count <= low.length))
{
high[1] = high[0];
high[0] = number;
}
if((number <= low[0]) || (count <= low.length))
{
low[1] = low[0];
low[0] = number;
}
}while(isInteger);
if(count != 0)
{
System.out.println(“The first number entered was: “+ first);
System.out.println(“The last number entered was: “+ number);
System.out.println(“The total amount of numbers entered was: “+ count);
System.out.println(“The highest two values inputted are: “+ high[0] +” and “+ high[1]);
System.out.println(“The lowest two values inputted are: “+ low[0] +” and “+ low[1]);
System.out.println(“The sum of all inputted numbers is: “+ sum);
System.out.println(“The average of all inputted numbers is: “+ sum/count);
}
scan.close();
System.out.println(“\n The End of the Line.”);
System.exit(1);
}
}