answersLogoWhite

0


Best Answer

import java.io.*;

class AvgWordSent

{

protected static void main()throws IOException

{

BufferedReader in=new BufferedReader(new InputStreamReader(System.in));

System.out.print("Enter the Sentence: ");

String s=in.readLine();

byte a=0,b=0;

float c=0;

for(byte i=0;i<s.length();i++)

{

if(s.charAt(i)==' ')

a++;

}

String w[]=new String[a+1];

for(byte i=0;i<=a;i++)

w[i]="";

for(byte i=0;i<s.length();i++)

{

if(s.charAt(i)==' ')

{

b++;

continue;

}

w[b]+=s.charAt(i);

}

b++;

for(byte i=0;i<=a;i++)

c+=w[i].length();

System.out.print("Average no. of words= "+(c/b));

}

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program in java to print average no of alphabets present in each word?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you write alphabets in order?

You can't write alphabets in order but you can write letters in order.


How do you write initially alphabets in urdu?

i just want to how to write initial alphabets in urdu ? i just want to how to write initial alphabets in urdu ?


How do you write china in traditional alphabets?

hybgg


Could you Write a program for 8086 microprocessor that displays on the monitor the average of 2 numbers from an array?

How to write a program for mouse in microprocessor?


Write a c program to generate student mark details using union and find total and average and grade?

write a c program to display marks,total,average,grade using union


What is a boy's education?

to teach a boy how to read write and learn alphabets


Write a java program that prints all alphabets?

class TestApp { public static void main(String args[]) { char ch; for( ch = 'a' ; ch &lt;= 'z' ; ch++ ) System.out.println(ch); } }


How do you write Israeli?

There is no language called Israeli. People speak Hebrew and they write using Hebrew alphabets.


How do you remember directions on a map?

Memorize and or write the coordinates on the sides of the map (alphabets and numbers )


How do you write the average n numbers program in c language?

Write your program and if you are having a problem post it here with a description of the problem you are having. What you are asking is for someone to do your homework for you. no i am asking to verify my answer


How do you write a C program to input a string of lowercase alphabets and convert it to uppercase using a loop?

void to_uppercase (char* str) { if (str == 0) return; while (*str != '\0') { if (*str&gt;='a' &amp;&amp; *str&lt;='z') *str-=32; ++str; } }


What is the present participle of write?

Writing.Writing is the present participle of write.