Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can some one help with this program. Here is the question. write a script that r

ID: 3560059 • Letter: C

Question

Can some one help with this program.

Here is the question.

write a script that reads several lines of text from the keyboard and prints a table indicating the number of occurances of each letter of the alphabet in the text. For example

To be, or not to be: that is the question:

Contains one "a", two "b's", no "c's" etc

I cannot ge it to count the letters.

Below is the program

<html>
<head>
<title>CountThem</title>
<script type="text/javascript">
<!--
function search1()
{
var str1 = document.getElementById("string1").value;
var str2 = new Array ("a", "b", "c" , "d", "e", "f", "g" , "h" , "i", "j", "k" , "l" , "m", "n" , "o" , "p" , "q", "r", "s", "t" , "u", "v", "w" , "x", "y" , "z");
var str11=str1.toLowerCase();
var len=str11.length;
document.getElementById("ans").value="" ;
for(i=0;i<26;i++)
{
var count=0;
var search=str11.indexOf(str2[i]);
for(j=0;j<len;j++)
{
if(parseInt(search)!= -1)
{
count++;
var search=str11.indexOf(str2[i],parseInt(search)+1);
}
}
if(count!=0)
{
document.getElementById("ans").value= document.getElementById("ans").value + " " + str2[i] + " Occurs " + count + " times";
}
}
}
// -->
</script>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">&nbsp;</td>
<h1>CountThem</h1>
<hr />

<p>Press F5 or Refresh to load script again. This is a program to determine the total number of occurrences of each letter of the alphabet in the text .</p>
<form name = "search" action = "">
<table border = "1">
<caption>Search</caption>
<tr><td>Enter any String</td>
<td><input name = "string1" type = "text" />
</td></tr>
<tr><td>Search Result</td>
<td><textarea name="ans" rows="26" cols="20">
</textarea>
</td></tr>
<tr><td><input type = "button" value = "CountThem"
/></td></tr>
</table>
</form>
</td>
</tr>
</table>

</body>
</html>

Explanation / Answer

java code