1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
maks197457 [2]
1 year ago
13

LAB: Word frequencies - methods Define a method named getWordFrequency that takes an array of strings, the size of the array, an

d a search word as parameters. Method getWordFrequency then returns the number of occurrences of the search word in the array parameter (case insensitive). Then, write a main program that reads a list of words into an array, calls method getWordFrequency repeatedly, and outputs the words in the arrays with their frequencies. The input begins with an integer indicating the number of words that follow. Assume that the list will always contain less than 20 words. Ex: If the input is: 5 hey Hi Mark hi mark the output is: hey 1 Hi 2 Mark 2 hi 2 mark 2 Hint: Use the equalsignoreCase() method for comparing strings, ignoring case. The program must define and call a method: public static int getWordFrequency(String[] wordsList, int listSize, String currWord) LAB ACTIVITY 8.45.1: LAB: Word frequencies - methods 0 / 10 LabProgram.java Load default template... Слд 1 import java.util.Scanner; 2 3 public class LabProgram { 4 5 /* Define your method here */ 6 7 public static void main(String[] args) { 8 /* Type your code here. */ 9 } 10 } 11 NO
Computers and Technology
1 answer:
BartSMP [9]1 year ago
5 0

Using the knowledge in computational language in JAVA it is possible to write the code being methods define a method named getWordFrequency that takes an array of strings

<h3>Writting the code in JAVA:</h3>

<em>import java.util.*;</em>

<em />

<em>public class WordFrequency {</em>

<em>        public static int getWordFrequency(String[] wordsList , int listSize , String currWord) {</em>

<em>                HashMap<String , Integer> hm = new HashMap<>();</em>

<em>                for(String st : wordsList) {</em>

<em>                        String str = st.toLowerCase();</em>

<em>                        hm.put(str, hm.getOrDefault(str, 0) + 1);</em>

<em>                }</em>

<em>                for(String st : wordsList) {</em>

<em>                        String str = st.toLowerCase();</em>

<em>                        System.out.println(st + " " + hm.get(str));</em>

<em>                }</em>

<em>                String currWordToLowerCase = currWord.toLowerCase();</em>

<em>                return hm.get(currWordToLowerCase);</em>

<em>        }</em>

<em>        public static void main(String[] args) {</em>

<em>                // TODO Auto-generated method stub</em>

<em>                String[] wordsList = {"hey" , "Hi" , "Mark" , "hi" , "mark"};</em>

<em>                int listSize = wordsList.length;</em>

<em>                String currWord = "hey";</em>

<em>                System.out.println("The frequency of " + currWord + " is : " + getWordFrequency(wordsList , listSize , currWord));</em>

<em>        }</em>

<em />

<em>}</em>

See more about JAVA at brainly.com/question/12978370

#SPJ1

You might be interested in
Write an application that inputs a telephone number as a string in the form (555) 555-5555. The application should use String me
Scilla [17]

Answer:

See explaination

Explanation:

// File: TelephoneNumber.java

import java.util.Scanner;

public class TelephoneNumber

{

public static void main(String[] args)

{

Scanner input = new Scanner(System.in);

String inputNumber;

String tokens1[];

String tokens2[];

String areaCode;

String firstThree;

String lastFour;

String allSeven;

String fullNumber;

/* input a telephone number as a string in the form (555) 555-5555BsAt4ube4GblQIAAAAASUVORK5CYII= */

System.out.print("Enter a telephone number as '(XXX) XXX-XXXX': ");

inputNumber = input.nextLine();

System.out.println();

/* use String method split */

tokens1 = inputNumber.split(" ");

/* extract the area code as a token */

areaCode = tokens1[0].substring(1, 4);

/* use String method split */

tokens2 = tokens1[1].split("-");

/* extract the first three digits of the phone number as a token */

firstThree = tokens2[0];

/* extract the last four digits of the phone number as a token */

lastFour = tokens2[1];

/* concatenate the seven digits of the phone number into one string */

allSeven = firstThree + lastFour;

/* concatenate both the area code and the seven digits of the phone number into one full string separated by one space */

fullNumber = areaCode + " " + allSeven;

/* print both the area code and the phone number */

System.out.println("Area code: " + areaCode);

System.out.println("Phone number: " + allSeven);

System.out.println("Full Phone number: " + fullNumber);

}

}

8 0
3 years ago
This is a free point thing!! I am giving 100 points!! Anyone wanna talk!!!!
julia-pushkina [17]

Answer:

:)

Explanation:

8 0
3 years ago
Read 2 more answers
give an example of a technical issue you were not able to resolve on your first attempt. What troubleshooting steps did you take
erastovalidia [21]
One technical issue I had was on Windows 8.1, with the charm menu not working. The troubleshooting steps to fix it was I did CTRL+SHIFT+ESC to open task manager. I then found Windows Explorer and clicked "Reload." Then everything was fine.

Hope This Helped!
6 0
3 years ago
How has technology effected the way we communicate?
horsena [70]

Indeed it has.

Advancements in technology and changes in communication generally go hand in hand. Landlines displaced the telegraph and cell phones replaced landlines. The arrival of the internet opened new doors of personal communication. E-mails replaced postal mails and social media took the place of text messages.

Communication technology, such as mobile phones, email, text messaging, instant messaging and social networking have had a profound effect on nearly everyone's business and personal lives. While technology makes communications faster and easier, at times it can also be intrusive and misinterpreted.

Increased isolation, reduced social interaction and social skills, and increased human-to-machine interactions are all a result of an overuse of technology, which has created a wall between many people globally.

Technology has the ability to enhance daily living from appliances to mobile devices and computers, technology is everywhere. ... In the rise of digital communication, technology can actually help communication skills because it allows people to learn written communication to varying audiences.

<em>-Astolfo</em>

3 0
3 years ago
Electricity fact topic
gregori [183]
''for kids'' i think thats what that mean
5 0
3 years ago
Read 2 more answers
Other questions:
  • In a student​ database, a row that describes the top​ student, including his or her​ lastname, firstname, and​ studentnumber, is
    9·1 answer
  • Esther has acquired an associate's degree in information technology and certifications in PageMaker and Illustrator. Which caree
    8·2 answers
  • The __________ vulnerability assessment is a process designed to find and document selected vulnerabilities that are likely to b
    15·1 answer
  • Question 1 Multiple Choice Worth 5 points)
    10·1 answer
  • How many bits are used to direct traffic to specific services running on a networked computer?
    6·1 answer
  • Question 4: What will be the output of the code? Show a complete analysis.
    6·1 answer
  • Which network media uses different regions of the electromagnetic spectrum to transmit signals through air?
    13·1 answer
  • What are some difficulties in synchronizing audio and video during telecine transfer? (Select all that apply.)
    13·1 answer
  • Which audio media can be directly sent to the subscribers through an RSS feed?
    6·1 answer
  • Calculate the time complexity for the following function in terms of Big O notation. Explain your answer.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!