lab#2 cet-3640

Lab Description:

In this lab we are to get the first last number we but in, The counter number maximum, minimum ,average and the total sum. i use the “while” command to make the loop that don’t stop till i input 0 to stop it. Than i use the “if” command to get the number i need.

Code:

package lab2;

//CET3640
import java.util.Scanner;
public class lab22 
{

	public static void main(String[] args)
	{

		Scanner input = new Scanner( System.in );

		int InputNumber=1;
		int firstnum = 0;
		int lastnum = 0; 
		int minimum =920006372; 
		int maximum = 0; 
		int average = 0;
		int count = 0;
		int sum = 0;

		while (InputNumber!=0)
		{
			System.out.print("Enter A Number,to exit enter 0: ");
			InputNumber = input.nextInt();
			sum += InputNumber;

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

			if (InputNumber 0 ){	
				lastnum = InputNumber;
			}

		}

		System.out.printf("First Number %d\n: ", firstnum);
		System.out.printf("Last Number %d\n: ", lastnum);
		System.out.printf("Maximum %d\n: ", maximum);
		System.out.printf("Minimum %d\n: ", minimum);
		System.out.printf("Average %d\n: ", sum/count);
		System.out.printf("Count %d\n: ", count);
		System.out.printf("Totel Sum %d\n: ", sum);
	}	
}

Screen shot: