Friday, August 10, 2012

Linear Search


Linear Search
Output
Linear Search List
44 index  position 7

Source code
package com.swain.cell;

public class LinearSearch {
       public static void main(String[] args)
       {
              System.out.println("Linear Search List");
             
              int[] arr = {0,2879, 15, 29, 78, 26, 24, 44, 167, 13,24,47};
             
              int i;       
              int num = 44;
              boolean flag=false;
             
              for(i=0; i<arr.length; i++){
                     if(arr[i]==num){
                           flag=true;
                           break;
                     }
                    
              }//for
             
              if(flag){
                     System.out.println(num + " index  position "+i);
              }
              else{
                     System.out.println(num + " no not found");
              }
             
       }     

}

How to Calculate the Future Investment Value of Investment.

Below java program for calculate future investment value. Here calculate s using the formula futureInvestmentValue =investmentAmount x (...