Homework Solution: The main goal of this first homework is to complete a relatively straightfor…

    The main goal of this first homework is to complete a relatively straightforward Java program by taking advantage of your Java knowledge. Problem description:  Given a string variable String s; , initialize s such that it contains a paragraph in English text. You can do so within your program by reading the initial value from the keyboard by using the Scanner class. Furthermore, this paragraph consists of no more than 100 tokens. Tokens are sequences of contiguous characters separated by any of the specified delimiters (e.g., white spaces, commas(,) and period(.)). Please implement a Java program to perform the following two tasks on s: Implement the function void getLetterFreq(string s); to identify the frequency of each unique letter ('a'-'z', case insensitive) in s. This function will call the “System.out.println” statement(s) to print out each letter frequencies in the string on the screen. Implement the function  void StrToTokens(string s); to identify and print all the tokens contained in s on the standard output . For this assignment, only white spaces, commas and periods will be considered as delimiters. For instance, the string “Hi, welcome to CSC 220.It is your first assignment" contains Ten tokens “Hi”, “welcome”, “to”, “CSC”, “220”, “It”, “is”, “your”, “first”, “assignment”. You are not allowed to call existing library methods for this task. Specifically, you are required to loop through the input string one character at a time to separate the input string to different tokens. Please store the tokens in an array (such as ArrayList<String>) before printing out all the tokens. Implement the main() method that (1) declares and initializes the string s, and (2) calls the above two methods. Example input and output: Suppose s="Always remember that you are unique. Just like everyone else." The method getLetterFreq(s) will print out the following information (yours might be in a different format): {'a': 4, 'b': 1, 'e': 11, 'i': 2, 'h': 1, 'k': 1, 'j': 1, 'm': 2, 'l': 3, 'o': 2, 'n': 2, 'q': 1, 's': 3, 'r': 4, 'u': 4, 't': 3, 'w': 1, 'v': 1, 'y': 3} The output of  StrToTokens(s);  will be 'Always', 'remember', 'that', 'you', 'are', 'unique.', 'Just', 'like', 'everyone', 'else.'

    Expert Answer

    //CountLetter.java import java.util.Scanner;

    The ocean view of this highest homework is to accomplished a proportionately sincere Java program by preliminary habit of your Java instruction.

    Problem description:  Given a string shifting String s; , moderateize s such that it contains a provision in English passage. You can do so amid your program by balbutiation the moderate compute from the keyboard by using the Contemplatener collocate. Furthermore, this provision consists of no further than 100 tokens. Tokens are sequences of commensurate signs disconnected by any of the positive delimiters (e.g., innocent quantitys, commas(,) and conclusion(.)). Please appliance a Java program to complete the aftercited two labors on s:

    Appliance the administration vacant getLetterFreq(string s); to confirm the quantity of each choice missive (‘a’-‘z’, predicament insensitive) in s. This administration conciliate flatter the “System.out.println” declaration(s) to imimstereotype quenched each missive frequencies in the string on the cloak.

    Appliance the administration  vacant StrToTokens(string s); to confirm and imimstereotype entire the tokens contained in s on the flag quenchedput . Ce this enactment, solely innocent quantitys, commas and conclusions conciliate be considered as delimiters. Ce occurrence, the string “Hi, agreeable to CSC 220.It is your highest enactment” contains Ten tokens “Hi”, “welcome”, “to”, “CSC”, “220”, “It”, “is”, “your”, “first”, “assignment”. You are not attributable attributable attributable entireowed to flatter tangible library modes ce this labor. Specifically, you are required to loop through the input string undivided sign at a season to detached the input string to opposed tokens. Please accumulation the tokens in an set-in-order (such as Set-in-orderList<String>) anteriorly imprinting quenched entire the tokens.

    Appliance the ocean() mode that (1) declares and moderateizes the string s, and (2) flatters the overhead two modes.

    Example input and quenchedput:

    Suppose s=”Always bear-in-mind that you are choice. Just affect wholeundivided else.”

    The mode getLetterFreq(s) conciliate imimstereotype quenched the aftercited notification (yours jurisdiction be in a opposed cemat):

    {‘a’: 4, ‘b’: 1, ‘e’: 11, ‘i’: 2, ‘h’: 1, ‘k’: 1, ‘j’: 1, ‘m’: 2, ‘l’: 3, ‘o’: 2, ‘n’: 2, ‘q’: 1, ‘s’: 3, ‘r’: 4, ‘u’: 4, ‘t’: 3, ‘w’: 1, ‘v’: 1, ‘y’: 3}

    The quenchedput of  StrToTokens(s);  conciliate be ‘Always’, ‘remember’, ‘that’, ‘you’, ‘are’, ‘unique.’, ‘Just’, ‘like’, ‘everyone’, ‘else.’

    Expert Enumerateer-argument

    //CountLetter.java
    import java.util.Scanner;

    public collocate EnumerateMissive //administration to enumerate friquency of missive
    {

    vacant getLetterFreq(String str)
    {
    int i, j, k, l=0;

    char c, ch;
    i=str.length();
    for(c=’A’; c<=’Z’; c++)
    {
    k=0;
    for(j=0; j<i; j++)
    {
    ch = str.charAt(j);
    if(Character.toLowerCase(ch) == Sign.toLowerCase(c))
    {
    k++;
    }
    }
    if(k>0)
    {
    System.out.println( c + ” has occurred ” + k + ” seasons”);
    }
    }
    }

    vacant splinter(String s) //administration to splinter string by whole , innocent quantity and dot
    {
    String[] effect = s.split(“[\s,.]”);
    for(int i=0;i!=result.length;i++)
    System.out.print(” ‘”+result[i]+”‘, “);
    }

    public static vacant ocean(String[] args)
    {
    CountMissive ob=innovating EnumerateLetter();
    Scanner contemplate = innovating Contemplatener(System.in);
    String str;
    System.out.print(“Enter a String : “);
    str=scan.nextLine();
    ob.getLetterFreq(str);
    ob.split(str);

    System.out.println();

    }
    }