Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- public class arg12
- {
- static BufferedReader in = new BufferedReader (new InputStreamReader(System.in));
- public static void main(String args []) throws IOException
- {
- System.out.print("enter size of array: ");
- int x= 0;
- x=Integer.parseInt(in.readLine());
- int c=0;
- c=x%2;
- if (c==1){
- System.out.print("size of array is not a even number");
- }
- else{
- int [] p= new int [x];
- for(int y=0;y<x;y++)
- {
- System.out.print("enter element for array#"+(y+1)+": ");
- p[y]=Integer.parseInt(in.readLine());
- }
- int o = p.length;
- System.out.println("**********************");
- int t = 0;
- t= o/2;
- int r =0;
- r = t-1;
- double e=0;
- e = (p[t]+p[r]);
- double e1 = 0;
- e1 = e/2;
- System.out.println("array elem1: "+p[t]);
- System.out.println("array elem2: "+p[r]);
- System.out.println("array length: "+o);
- System.out.println("middle array number: "+t);
- System.out.println("median: "+e1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement