Write a program in Java that will check what is the highest and lowest number given by the user using one dimensional array.
I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.Please subscribe to my channel https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGg
Thank you very much for your support.
Program Listing
// smallest_biggest_number.java
// Written By: Mr. Jake R. Pomperada, MAED-IT
// Date : July 7, 2015
// Email Address: jakerpomperada@yahoo.com
// jakerpomperada@gmail.com
// Problem : Write a program in Java that will check what is the highest and
// lowest number given by the user using one dimensional array.
import java.util.Scanner;
public class smallest_highest {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int[] num= new int[10];
System.out.print("\n\n");
System.out.print("\t\tSMALLEST AND HIGHEST NUMBER IN JAVA ");
System.out.print("\n\n");
System.out.print("How many items ? : ");
int n=input.nextInt();
int smallest = Integer.MAX_VALUE;
int biggest =Integer.MIN_VALUE;
for(int i =0;i<n;i++) {
int y=i+1;
System.out.print("Enter item value no. " + y + " value : ");
num[i]=input.nextInt();
if(num[i] < smallest) {
smallest = num[i];
}
if (num[i] > biggest) {
biggest = num[i];
}
}
System.out.println();
System.out.println("The Smallest number is " +smallest + ".");
System.out.println("The Biggest number is " +biggest +".");
System.out.println();
System.out.println("\t\t END OF PROGRAM");
System.out.println("\n\n");
input.close();
}
}