# Lab 2

Lab Description:

The objective of this lab is to get us to enter multiply number and get the out put to show first number entered, last number entered, count numbers entered, minimum, maximum, total Sum, and average. This was done using the scanner input. The first number entered was done by setting the program to start counting soon as the user entered the first number. To find last number entered was difficult but it was done by setting the program to break once the user entered the number 0 and then to count the number right before it.

Code:

```package lab2;

import java.util.Scanner;
public class Lab2 {

public static void main(String[] args)
{

Scanner input = new Scanner( System.in );

int numentered=0;
int firstnum = 0;
int lastnum = 0;
int minimum =10000;
int maximum = 0;
int average = 0;
int count = 0;
int sum = 0;

while (true)
{
System.out.print("Enter any number you would like too,to exit please enter 0: ");
numentered = input.nextInt();
sum += numentered;

if (numentered >= maximum){
maximum = numentered;
}
if( numentered ==0 ) break;

if (numentered 0 ){
lastnum = numentered;

}
count++;
if ( count ==1 ){
firstnum = numentered;

}
if ( count >0 ){
lastnum = numentered;
}
System.out.printf("First Number entered %d\n: ", firstnum);
System.out.printf("Last Number entered %d\n: ", lastnum);
System.out.printf("Count %d\n: ", count);
System.out.printf("Maximum %d\n: ", maximum);
System.out.printf("Minimum %d\n: ", minimum);
System.out.printf("Total Sum %d\n: ", sum);
System.out.printf("Average %d\n: ", sum/count);

}

}```

Screen Shot: 