Explanation of Solution
Modified class “Vocabulary” that uses “Set” instead of “ArrayList”:
//Import required packages
import java.util.*;
import java.io.*;
//Definition of class Vocabulary
public class Vocabulary {
//Definition of main method
public static void main(String[] args)
throws FileNotFoundException
{
//Create an object for scanner class
Scanner sc = new Scanner(System.in);
//Call the method printIntro()
printIntro();
//Get the first file name
System.out.print("file #1 name? ");
String filename1 = sc.nextLine();
//Create an object for scanner class
Scanner file1 = new Scanner(new File(filename1));
//Get the second file
System.out.print("file #2 name? ");
String filename2 = sc.nextLine();
//Create an object for scanner class
Scanner file2 = new Scanner(new File(filename2));
System.out.println();
//Create an object for set
Set<String> set1 = getWordsFromFile(file1);
Set<String> set2 = getWordsFromFile(file2);
Set<String> overlap = new TreeSet(set1);
//Call the method retainAll
overlap.retainAll(set2);
//Call the method Result
Result(set1, set2, overlap);
}
//Definition of method getWordsFromFile
public static Set<String> getWordsFromFile(Scanner input) {
//Create an object for set
Set<String> result = new TreeSet<String>();
// read all words from the file
while (input.hasNext()) {
//Get the values and store it in val
String val = input.next().toLowerCase();
//Add the value to the result
result...
Want to see the full answer?
Check out a sample textbook solutionChapter 11 Solutions
Building Java Programs: A Back To Basics Approach, Loose Leaf Edition (5th Edition)
- make a screen capture showing the StegExpose resultsarrow_forwardWhich of the following is not one of the recommended criteria for strategic objectives? Multiple Choice a) realistic b) appropriate c) sustainable d) measurablearrow_forwardManagement innovations such as total quality, benchmarking, and business process reengineering always lead to sustainable competitive advantage because everyone else is doing them. a) True b) Falsearrow_forward
- Vision statements are more specific than strategic objectives. a) True b) Falsearrow_forwardThe three components of the __________ approach to corporate accounting include financial, environmental, and social performance measures. Multiple Choice a) stakeholder b) triple dimension c) triple bottom line d) triple efficiencyarrow_forwardCompetitors, as internal stakeholders, should be included in the stakeholder management consideration of a company and in its mission statement. a) True b) Falsearrow_forward
- At what level in the organization should the strategic management perspective be emphasized? Multiple Choice a) throughout the organization b) from the bottom up in an organization c) at the top of the organization d) at the middle of the organizationarrow_forwardA good manager can be flexible when it comes to sticking to the original plan; to get good results, the intended strategy has to become the realized strategy. a) True b) Falsearrow_forward________ tend to be quite enduring and seldom change. Multiple Choice a) Strategic objectives b) Vision statements c) Strategic plans d) Mission statementsarrow_forward
- The idea that organizations are not only accountable to stockholders but also to the community-at-large is known as social responsibility. a) True b) Falsearrow_forwardAmong the leaders needed for an effective strategic management process are ________, who, although they have little positional power and formal authority, generate their power through the conviction and clarity of their ideas. Multiple Choice a) executive leaders b) triple bottom line advocates c) internal networkers d) local line leadersarrow_forwardI would like to get help to resolve the following casearrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education