Advertisement
apez1

Term 1: Lesson 34 - Coding Activity 4

Nov 28th, 2018
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.52 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.math.*;
  3.  
  4. public class Lesson_34_Activity_Four {
  5.    
  6.     static Scanner scanner = new Scanner(System.in);
  7.    
  8.     public static int findMin(int []a) {
  9.         int smallest = a[0];
  10.                
  11.         for(int i=0; i<a.length;i++) {
  12.             if(a[i] < smallest) {
  13.                 smallest = a[i];   
  14.             }  
  15.         }
  16.         return smallest;
  17.        
  18.        
  19.     }
  20.  
  21.    
  22.  
  23.     public static void main(String[] args) {   
  24.    
  25.     int a[] = {100,24,8,4,42,4};
  26.    
  27.     int x = findMin(a);
  28.    
  29.     System.out.println(x);
  30.    
  31.    
  32.     }
  33.    
  34.    
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement