Lab-2

public class Explab2 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner( System.in ); int InputNumber=0; int firstnum = 0; int lastnum = 0; int minimum = 10987659; int maximum = 0; int average = 0; int count = 0; int sum = 0; while (true) { 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 <= minimum){ minimum = InputNumber; } count++; if ( count ==1 ){ firstnum = InputNumber; } if ( count >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); } } Exp lab2

Description: Lab 2

The mean objective of this lab is to understand how Java programming language and syntax are relate to each other. The way syntax and the Java programming work, is like a loop statement. When a number is execute we see that the user number computer several statistics. I also find another undesirable error, in which in this experiment I had problem to run the program, the problem that I found was saying that I have 1 syntax error, I tried to change the code many way.

 

printSc

Exp lab2