Access Millions of academic & study documents

All the methods are completed Write a class named WordCruncherTest

Content type
User Generated
Showing Page:
1/3
All the methods are completed.
Write a class named WordCruncherTest that has only a
main method that:
The program should continue to do this until the user
enters the word \"quit\"
Solution
import static java.lang.System.exit;
import java.util.Scanner;
class WordCruncherTest
{
public static void main(String args[])
{
Scanner m=new Scanner(System.in);
String option = \"\";
option=m.next();
if(option.equals(\"quit\"))
{
System.out.println(\"bye\");
exit(0);
}
else

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/3
{
int[] alphabetArray = new int[26];int coun=0;
for ( int i = 0; i < option.length(); i++ ) {
char ch= option.charAt(i);
int value = (int) ch;
if (value >= 97 && value <= 122){
alphabetArray[ch-\'a\']++;
coun++;
}
}
for (int i = 0; i < alphabetArray.length; i++) {
if(alphabetArray[i]>0){
char ch = (char) (i+97);
System.out.println(\" occurences : \"+ch+\"
\"+alphabetArray[i]+\"\"); //Show the result.
}
}
System.out.println(\"number of letters are\"+coun);
char[] try1= option.toCharArray();
System.out.println(\"string reverse\");
for (int i=try1.length-1;i>=0;i--)
System.out.print(try1[i]);
System.out.println(\"\");
int count=0;
for (int i = 0; i < option.length(); i++) {

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/3

Sign up to view the full document!

lock_open Sign Up
Unformatted Attachment Preview
All the methods are completed. Write a class named WordCruncherTest that has only a main method that: The program should continue to do this until the user enters the word \"quit\" Solution import static java.lang.System.exit; import java.util.Scanner; class WordCruncherTest { public static void main(String args[]) { Scanner m=new Scanner(System.in); String option = \"\"; option=m.next(); if(option.equals(\"quit\")) { System.out.println(\"bye\"); exit(0); } else { int[] alphabetArray = new int[26];int coun=0; for ( int i = 0; i < option.length(); i++ ) { char ch= option.charAt(i); int value = (int) ch; if (value >= 97 && value 0){ char ch = (char) (i+97); System.out.println(\" occurences : \"+ch+\" \"+alphabetArray[i]+\"\"); //Show the result. } } System.out.println( ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Indeed
4.5
Sitejabber
4.4