7. Write a program by using Scanner class to input a sentence. Display each word
of the sentence along with the sum of the ASCII codes of its characters.
Answers
Answered by
1
Answer:
for(int i=0;i<len;i++)
{
char ch= str. charAt(i);
if(ch!=" ")
char w=w+ch;
else
int l = w.length();
for(int j=0; j<l; j++)
{
int z=(int)w.charAt(j);
int sum=sum+z;
System.out.println("word="+w);
System.out.println("Ascii sum="+sum);
sum=0;
}
w="";
}
Similar questions