Friday, 17 July 2015

Java Programming

Q). Retrieve the elements in a array, which is an input, which are greater than a specific input number. Add them and find the reverse of the sum.

  1. package Set1;
  2. public class ClassSet46 {
  3. public static void main(String[] args) {
  4.       int[] a={23,35,11,66,14,32,65,56,55,99};
  5.       int b=37;
  6.       System.out.println(additionOfRetrievedElements(a,b));
  7.       }
  8. public static int additionOfRetrievedElements(int[] a, int b) {
  9.       int n=0;
  10.       for(int i=0;i<a.length;i++)
  11.             if(a[i]>b)
  12.                   n+=a[i];
  13.       return n;
  14. }
  15. }