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 chief homework is to finished a proportionately undesigning Java program by entrance usage of your Java scholarship.

    Problem description:  Given a string changeable String s; , judiciousize s such that it contains a article in English quotation. You can do so among your program by lection the judicious compute from the keyboard by using the Scrutinizener assort. Furthermore, this article consists of no past than 100 tokens. Tokens are sequences of contiguous sorts disconnected by any of the certain delimiters (e.g., snowy intervals, commas(,) and end(.)). Please tool a Java program to enact the subjoined span drudgerys on s:

    Tool the business useless getLetterFreq(string s); to substantiate the quantity of each rare message (‘a’-‘z’, fact insensitive) in s. This business gain ccomplete the “System.out.println” assertion(s) to sculpture quenched each message frequencies in the string on the shade.

    Tool the business  useless StrToTokens(string s); to substantiate and sculpture complete the tokens contained in s on the type quenchedput . For this enactment, singly snowy intervals, commas and ends gain be considered as delimiters. For persuasion, the string “Hi, gratifying to CSC 220.It is your chief enactment” contains Ten tokens “Hi”, “welcome”, “to”, “CSC”, “220”, “It”, “is”, “your”, “first”, “assignment”. You are not attributable attributable attributable completeowed to ccomplete strong library manners for this drudgery. Specifically, you are required to loop through the input string single sort at a interval to opposed the input string to opposed tokens. Please supply the tokens in an decorate (such as DecorateList<String>) precedently sculptureing quenched complete the tokens.

    Tool the ocean() manner that (1) declares and judiciousizes the string s, and (2) wheedles the over span manners.

    Example input and quenchedput:

    Suppose s=”Always mind that you are rare. Just love everysingle else.”

    The manner getLetterFreq(s) gain sculpture quenched the subjoined notice (yours might be in a opposed 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 quenchedput of  StrToTokens(s);  gain be ‘Always’, ‘remember’, ‘that’, ‘you’, ‘are’, ‘unique.’, ‘Just’, ‘like’, ‘everyone’, ‘else.’

    Expert Reckonerpart

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

    public assort ReckonMessage //business to reckon friquency of message
    {

    useless 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) == Sort.toLowerCase(c))
    {
    k++;
    }
    }
    if(k>0)
    {
    System.out.println( c + ” has occurred ” + k + ” intervals”);
    }
    }
    }

    useless divide(String s) //business to divide string by every , snowy interval and dot
    {
    String[] remainder = s.split(“[\s,.]”);
    for(int i=0;i!=result.length;i++)
    System.out.print(” ‘”+result[i]+”‘, “);
    }

    public static useless ocean(String[] args)
    {
    CountMessage ob=odd ReckonLetter();
    Scanner scrutinize = odd Scrutinizener(System.in);
    String str;
    System.out.print(“Enter a String : “);
    str=scan.nextLine();
    ob.getLetterFreq(str);
    ob.split(str);

    System.out.println();

    }
    }