Java: An Introduction to Problem Solving and Programming (7th Edition)
Java: An Introduction to Problem Solving and Programming (7th Edition)
7th Edition
ISBN: 9780133766264
Author: Walter Savitch
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 12, Problem 14PP
Program Plan Intro

Remove duplicates names from file

Program Plan:

  • Import required package.
  • Define “InvitationList” class.
    • Define main function.
      • Create “HashSet” for names.
      • Declare required variables.
      • Assign scanner object to “null”.
      • Inside the “try” block,
        • Define “namesList” file using “FileInputStream”.
        • Check condition using “while” loop.
          • Read name from file.
          • Check if the name is in the set or not. If the name is in the set already, then ignore it. If the name is not contains in the set, then add the given name to “names_set”.
        • Close the file.
        • Display statement.
        • Display all names in set using “for” loop
      • Catch the exception using “catch” keyword.
        • Display given error and exit the program.

Blurred answer
Students have asked these similar questions
Java Programming   This week's project involves a text file with that holds all of the novel Don Quixote*, by Miguel Cervantes. The text file has been heavily processed. It contains only lowercase letters, spaces, and new lines. That is a good format for counting words. Write code that reads through the text file one word at a time using a Scanner, and the next() method. Put the words into a HashMap, where the words are used as keys, and the values are Integers used to keep track of how many times the words occur in the text. If the text was "one fish two fish red fish blue fish one two three" then the HashMap would look like this:         key                value         "one"....        2         "fish"...        4         "two"....        2         "red"....        1         "blue"...        1         "three"..        1   Once you have created such a HashMap for the whole of the text you can write logic that prints out the answers to these questions: How many times does each of…
JAVA Create a new class HashMapManipulation with a main method. Import the necessary classes from the java.util package, including the HashMap class. Create a HashMap object, named mapand use the put() method to add key-value pairs to the map. The keys are strings "A", "B", and "C", and the values are integers 1, 2, and 3 respectively. Use the size() method to print the size of the map. Use a for loop to print the key-value pairs in the map. The loop should iterate over the entries in the map using the entrySet() method, which will return a set of Map.Entry objects representing the key-value pairs in the map. The key and value of each entry are printed using the getKey() and getValue() methods, respectively. Use theget() method to get the value of key "A", and assigns it to a variable value. The value is then printed. Use the put() method to add a new key-value pair to the map. The key is "D" and the value is 4. The map is then printed again, to show the added key-value…
How do I write this java program in hashmap? The program should create charts showing the consistency of the two judges. The rows represent the scores given by Dr. Stansifer and the columns represent the scores given by Dr. Shoaff. Suppose the maximum score is 3 the judges give the following scores. Manatee ID Dr. Shoaff's Score Dr. Stansifier's Score 1 0 0 23 0 3 14 0 0 5 3 0 19 2 3 18 1 1 12 3 2 204 1 1 6 0 0 25 3 3 The consistency chart resulting from these scores are:   0 1 2 3 0 3 0 0 1 1 0 2 0 0 2 0 0 0 1 3 1 0 1 1 The "3" in the upper left hand corner indicates that there were 3 manatees that Dr Shoaff and Dr Stansifer gave a 0 score. (namely manatee 1, 14, 6). The 1 in row 0, column 1 indicates there was 1 manatee that Dr. Shoaff scored a 0 while Dr Stansifer scores a 3 (namely manatee 23). Ideally the only non-zero entries in the table would be along the diagonal indicating perfect consistency. Your program should take a group of scores…

Chapter 12 Solutions

Java: An Introduction to Problem Solving and Programming (7th Edition)

Ch. 12.1 - Prob. 12STQCh. 12.2 - Prob. 13STQCh. 12.2 - Prob. 14STQCh. 12.2 - Prob. 15STQCh. 12.2 - Prob. 16STQCh. 12.3 - Prob. 17STQCh. 12.3 - Prob. 18STQCh. 12.3 - Prob. 19STQCh. 12.3 - Write a definition of a method isEmpty for the...Ch. 12.3 - Prob. 21STQCh. 12.3 - Prob. 22STQCh. 12.3 - Prob. 23STQCh. 12.3 - Prob. 24STQCh. 12.3 - Redefine the method getDataAtCurrent in...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.4 - Revise the definition of the class ListNode in...Ch. 12.4 - Prob. 30STQCh. 12 - Repeat Exercise 2 in Chapter 7, but use an...Ch. 12 - Prob. 2ECh. 12 - Prob. 3ECh. 12 - Repeat Exercises 6 and 7 in Chapter 7, but use an...Ch. 12 - Write a static method removeDuplicates...Ch. 12 - Write a static method...Ch. 12 - Write a program that will read sentences from a...Ch. 12 - Repeat Exercise 12 in Chapter 7, but use an...Ch. 12 - Write a program that will read a text file that...Ch. 12 - Revise the class StringLinkedList in Listing 12.5...Ch. 12 - Prob. 12ECh. 12 - Write some code that will use an iterator to...Ch. 12 - Prob. 14ECh. 12 - Write some code that will use an iterator to...Ch. 12 - Prob. 17ECh. 12 - Revise the method selectionSort within the class...Ch. 12 - Repeat the previous practice program, but instead...Ch. 12 - Repeat Practice Program 1, but instead write a...Ch. 12 - Write a program that allows the user to enter an...Ch. 12 - Write a program that uses a HashMap to compute a...Ch. 12 - Write a program that creates Pet objects from data...Ch. 12 - Repeat the previous programming project, but sort...Ch. 12 - Repeat the previous programming project, but read...Ch. 12 - Prob. 9PPCh. 12 - Prob. 10PPCh. 12 - Prob. 11PPCh. 12 - Prob. 12PPCh. 12 - Prob. 13PPCh. 12 - Prob. 14PPCh. 12 - Prob. 15PP
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education