# Lab #3

to create a program to calculate the sum of a set of numbers. to get the first number, the last number, count how many numbers there were in the set.
ScreenShot:

Code:

public class NumberStats {
private int number;
private int firstnumber;
private int lastnumber;
private int count;
private double average;
private int maximum;
private int minimum;
private int totalnumber;
private int numbermmount;

public int getnumber() {
return number;
}
public int getfirstnumber() {
return firstnumber;
}

public int getlastnumber() {
return lastnumber;
}
public int getcount() {
return count++;
}
public double getaverage() {
return average;
}
public int getmaximum() {
return maximum;
}
public int getminimum() {
return minimum;
}
public int gettotalnumber() {
}
public int getnumberamount() {
return numbermmount;
}
}

//lab 3 by Julio Tax
import java.util.Scanner;
public class TrainStats {

public static void main(String[] args) {

int number = 0;
int numberamount = 0;
int totalnumber = 0;
int firstnumber = number;
int lastnumber = number %10;
int count =1;
double average;
int maximum = 0;
int minimum = 1;

Scanner input = new Scanner( System.in);

System.out.println(“Enter a series of number: “);
System.out.println(“Enter 0 when u finished: ”);

do {
number=input.nextInt();
numberamount ++;
totalnumber = totalnumber + number;

if (number > maximum)
{
maximum=number;
count=0;
}
if(number==maximum)
count++;

else if (number < minimum) { minimum=number; count=1; } if(number==minimum){ count ++; } if (count ==1){ firstnumber = number; } else if (count >0) {
lastnumber = number;
}
}

while (number !=0);

average=(double)totalnumber/(numberamount-1);
System.out.printf(“The average is %.2f\n”, average);

System.out.println(“the total number you entered: ” + numberamount);
System.out.println(“The sum for the numbers you entered is ” + totalnumber);
System.out.println(“The maximum number is\t: ” + maximum);
System.out.println(“The minimum number is: ” + minimum);

System.out.printf(“the first digit you entered is ” + firstnumber);
System.out.printf(“\nThe last digit you entered is ” + lastnumber);

NumberStats mystats1 = new NumberStats();
NumberStats mystats2= new NumberStats();
NumberStats mystats3 = new NumberStats();
NumberStats mystats4 = new NumberStats();
NumberStats mystats5 = new NumberStats();
NumberStats mystats6 = new NumberStats();
NumberStats mystats7 = new NumberStats();
NumberStats mystats8 = new NumberStats();

System.out.printf(“%s\n” , mystats1.getmaximum());
System.out.printf(“%s\n” , mystats2.getminimum());
System.out.printf(“%s\n” , mystats3.getaverage());
System.out.printf(“%s\n” , mystats4.getlastnumber());
System.out.printf(“%s\n” , mystats5.getfirstnumber());
System.out.printf(“%s\n” , mystats6.getnumber());
System.out.printf(“%s\n” , mystats7.getnumberamount());
System.out.printf(“%s\n” , mystats8.gettotalnumber());

}
}