Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- class Ex2 //Ex2 is Java Program Name
- {
- public static void main(String a[])
- {
- DataInputStream in = new DataInputStream(System.in);
- String name[] = new String[10];
- int length[] = new int[10];
- int i;
- float avg=0.0f, sum=0.0f;
- try
- {
- for(i=0;i<10;i++)
- {
- System.out.println("Enter Name : "+(i+1)+" :");
- name[i] = in.readLine();
- length[i] = name[i].length();
- sum = sum+length[i];
- }
- }
- catch(Exception e)
- {
- }
- for(i=0;i<10;i++)
- {
- System.out.println("Length Of "+name[i]+"is : "+length[i]);
- }
- System.out.println("Sum Of All The Names Length : "+sum);
- avg=sum/10;
- System.out.println("Average Length is :"+avg);
- }
- }
Add Comment
Please, Sign In to add comment