Virajsinh

Java_02

Jan 24th, 2018
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. import java.io.*;
  2.  
  3. class Ex2 //Ex2 is Java Program Name
  4. {
  5.     public static void main(String a[])
  6.     {
  7.         DataInputStream in = new DataInputStream(System.in);
  8.         String name[] = new String[10];
  9.         int length[] = new int[10];
  10.         int i;
  11.         float avg=0.0f, sum=0.0f;
  12.         try
  13.         {
  14.             for(i=0;i<10;i++)
  15.             {
  16.                 System.out.println("Enter Name : "+(i+1)+" :");
  17.                 name[i] = in.readLine();
  18.                 length[i] = name[i].length();
  19.                 sum = sum+length[i];
  20.             }
  21.         }
  22.         catch(Exception e)
  23.         {
  24.         }
  25.    
  26.         for(i=0;i<10;i++)
  27.         {
  28.             System.out.println("Length Of "+name[i]+"is : "+length[i]);
  29.         }
  30.    
  31.         System.out.println("Sum Of All The Names Length : "+sum);
  32.         avg=sum/10;
  33.         System.out.println("Average Length is :"+avg);
  34.     }
  35. }
Add Comment
Please, Sign In to add comment