Showing posts with label smallest number in Java. Show all posts
Showing posts with label smallest number in Java. Show all posts

Sunday, September 3, 2017

Minimum Value Checker in Java

A very simple program that I wrote using Java to check which of the list of numbers in an array is the smallest in terms of numerical value.  The code is very simple and easy to understand.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.



Sample Program Output



Program Listing


minimum_value.java


/**
 * 
 */
package array_demo;

/**
 * @author Jacob
 *
 */
public class minimum_value {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int a=0,min_value=0;
int b[] = {100,35,567,5,62};
min_value=b[0];
for (a=0; a<5; a++)
{
if (min_value > b[a])
{
min_value=b[a];
}
}

 System.out.println();
       System.out.println("Minimum Value Checker in Java");
       System.out.println();
       System.out.println("Written By Mr. Jake R. Pomperada, MAED-IT");
       System.out.println();
System.out.print("The Minimum value in the array is " + min_value + ".");
System.out.println("\n\n");
       System.out.println("End of Program");
       System.out.println();
}

}



Sunday, July 26, 2015

Smallest Number in Java

In this simple program that I wrote it will allows the user to give a series of numbers and then it will check and display the smallest number from the given number by the user using Java as our programming language.

If you have some questions about programming, about my work please send mu an email at jakerpomperada@gmail.comand jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.


Sample Program Output

Program Listing

/*
smallest_number_array.java
Programmer By: Mr. Jake R. Pomperada, MAED-IT
Date : July 23, 2015
Tools: NetBeans 8.0.2, Java SE 8.0

Problem No. 7:
  
Write a program that will ask the user to give five numbers and then
it will search for the smallest number in the given list from the user.
user.
*/
              

import java.util.Scanner;

class smallest_number_array{
    
public static void main(String[] args) {
      
     Scanner input = new Scanner(System.in);
     char ch;
                   
  do { 
      int [] values; 
      values  = new int[5];  
      int x=0;
      int smallest = Integer.MAX_VALUE;
      System.out.print("SMALLEST NUMBER PROGRAM");
      System.out.println();
      for (int a=0; a<5; a++)
      {
         x=1;
         x+=a;
         System.out.print("Enter value in item no. " + x + " : ");
         values[a] = input.nextInt();
        }       
         System.out.println(); 
         for(int a =0;a<5;a++) {
           if(smallest > values[a]) 
           {
            smallest = values[a];
            }
        }  
     System.out.println("The smallest number is " + smallest +".");
      System.out.print("\nDo you want to continue (Type y or n) : ");
     ch = input.next().charAt(0);                        
     } while (ch == 'Y'|| ch == 'y');  
     System.out.println();
     System.out.print("\t THANK YOU FOR USING THIS PROGRAM");
     System.out.println("\n\n");
  }
} // End of Code