The list of letters should be an alphabetical list of upper case letters followed by an alphabetical list of lower case letters.
Sample Test Cases:
Input #00:
When riding your bicycle backwards down a one-way street, if the
wheel falls of a canoe, how many ball bearings does it take to fill
up a water buffalo?
Hello Howard.
Output #00:
e 6
al 7
a 3
Hlo 2
Yes This is The Exact Working Code ..Enjoy
import java.util.*;
import java.io.*;
public class ReadFileSystem
{
public static void main(String args[])throws Exception
{
BufferedReader in = new BufferedReader(new FileReader("E:/ubuntu/test.txt"));//the file containing lines.
HashMap
String str="";
while ((str = in.readLine()) != null)
{
for (int i = 0; i < str.length(); i++)
{
Character c = str.charAt(i);
if (Character.isLetter(c))
{
if(lettercount.containsKey(c))
{
lettercount.put(c,lettercount.get(c) + new Integer(1));
}
else
{
lettercount.put(c,new Integer(1));
}
}
}
int maxCount = 0;
for(Integer count: lettercount.values())
{
if (count > maxCount)
{
maxCount = count;
}
}
StringBuffer characters =new StringBuffer();
for (Map.Entry
{
if (entry.getValue().equals(maxCount))
{
if(entry.getKey()>='A' && entry.getKey() <='Z')
{
characters.append(entry.getKey());
characters.reverse();
}
else
characters.append(entry.getKey());
}
}
System.out.print(characters);
System.out.println(" " + maxCount);
//resetting count value
for(Map.Entry
{
lettercount.put(entry.getKey(),0);
}
}
}
}
Cheers
2 comments :
hi can you give a code in c for the same problem.
@Diyya , just try to code it by own , let me know what problem u are facing ?
Post a Comment