# CET3640 – Software for Computer Control

## Lab #2

Objective: The objective with this lab was to get familiar with Eclipse, and start to do the second lab assignment. Basically, this program
will let the user compute several statistics. Also, the user  will be able to enter as many numbers as wished (positives or negatives). However, once the number are entered, can type 0 (zero) to get the result. This program was not easy to create because I am new to Java, however; it did not stop me to accomplish this lab. I was having a hard time to make it work, so read the slices from class and the book. I finally figured out what i was doing wrong and finish my program. Also by reading the book i learned some trick that it will help me in the future.

Code:

``` package lab2;

import java.util.Scanner;
public class lab2 {

/**
* @param args
*/
public static void main(String[] args)
{

Scanner input = new Scanner(System.in);

int value = 0; // It will do the job for us
int firstnumber = 0; // This will show the first number entered
int lastnumber = 0; // This will show the last number entered
int count = 0;// It will count
int minimum = 0; // This will show the minimum number entered
int maximun = 0; // It will show the maximum number entered
int average = 0; // It will show the average
int totalsum = 0; // It will add the numbers entered

while (true)
{
System.out.print("Input Number, type 0 to get result: ");
value = input.nextInt();
totalsum += value;

if (value >= maximun){
maximun = value;
}
if( value == 0 ) break;

if (value == minimum ){
minimum = value;

lastnumber = value;

}
count++;
if(count==1){
firstnumber=value;
minimum = value;
}

if (count>0){
lastnumber = value;
}
}
System.out.printf("First Number entered = %d\n", firstnumber);
System.out.printf("Last Number entered = %d\n", lastnumber);
System.out.printf("Count = %d\n", count);
System.out.printf("Maximum = %d\n", maximun);
System.out.printf("Minimum = %d\n", minimum);
System.out.printf("Average = %d\n", totalsum/count);
System.out.printf("Total Sum = %d\n", totalsum);
}
}```

### Screenshot: 