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

Read the highlighted paragraph shown below. Enter it in a program, anyway that y

ID: 3535457 • Letter: R

Question

Read the highlighted paragraph shown below. Enter it in a

program,

anyway that you want, and count how many of each letter

appeared.

Print the results out as

There were ### As

There were ### Bs

Blah blah blah


Then print the paragraph backwards.



It looks so

ordinary and plain that you would think nothing

A is

wrong with it. In fact, nothing is wrong with it! It

is

highly unusual

though. Study it and think about it,

A but

you still may not find anything odd. But if you work at it a

bit,

you might find

out. Try to do so without any coaching!


Explanation / Answer

class StrCount
{
public static void main(String args[])
{
int i, j, c=0;
String s = " It looks so ordinary and plain that you would think nothing is wrong with it. In fact, nothing is wrong with it! It is highly unusual though. Study it and think about it, but you still may not find anything odd. But if you work at it a bit, you might findout. Try to do so without any coaching!";
char[] a ={'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'};
for(i=0; i<26; i++)
{
c=0;
for(j=0; j<s.length(); j++)
{
if(a[i]==s.charAt(j))
c++;
}
System.out.println("There were " + c + " " + a[i] + "'s");
}

for(i=s.length()-1; i>=0; i--)
System.out.print(s.charAt(i));
}
}