Question: Write a class named Q1 and implement the following method: public static int [] getSpamStatistics (String [] names, String [] labels, string queryName) The method

Write a class named Q1 and implement the following method:
public static int [] getSpamStatistics (String [] names, String [] labels, string queryName)
The method gets two arrays:
names - an array of names of people (strings) who sent an email.
labels - an array of tags that indicate to each name whether the emails he sends are considered spam or non-spam or we do not know what type of email. The i-member in the labels array corresponds to the i member in the names array.
In addition the function gets the name of a sender (the queryName parameter).
Comments: It can be assumed that the labels array contains only the words "not_spam", "spam" and "unknown" (for emails that are spam, emails that are not spam and emails that we do not know what type, respectively).
In addition you can place names blueberry in different strings, without repetitions. The method performs two operations:
The method performs two operations
The method prints to the reporting screen about the sender named queryName. If there is a name of such a sender in the namespace the function prints to the screen:
The email sent by , is
where is the requested name and
No email was sent by
where is the requested name.
The method counts how many emails were received from each of the three types, and returns an array with the counts. The first place in the array indicates how many emails are "spam", the second place counts how many emails are not_spamt "and the third place counts how many emails are" unknown ".
Examples: If we pass the arrays to the method:
String [] names = {"Romy", "Niv", "Yehuda", "Nofar", "Aviram", "Rivki"}
Stringl labels - ("not_spam", "spam" , "unknown", "not_spam", "not spam", "unknown}
and the string:
query Name = Aviram "
The method will print The email sent by Aviram, is not_spam and return the array: {1, 3, 2 }
If we pass the same arrays and string to the method:" queryName = "Shay The method will print No email was sent by Shay
and return The array: {1,3, 2}
using java

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!