bartleby

Concept explainers

Question
Book Icon
Chapter 18, Problem 9PP
Program Plan Intro

Elimination of Duplicate Names

Program Plan:

  • Include required header file.
  • Include required “std” namespace.
  • Define main function
    • Declare variable for input file.
    • Declare a variable “ns” in “set” template class of “string” type.
    • Open the given input file.
    • If the input file is fail, then the program terminates.
    • Otherwise, performs “while” loop. This loop executes until the end of file.
      • Declare a variable “name” in “string” type.
      • Read the name from given input file.
      • Then insert a name into “set” template class. If any duplicate name contains, then it remove that name.
    • Close the file.
    • Display statement.
    • Declare a variable “np” in constant iterator of “set” template class.
    • Display the names to generate the invitation list after removing duplicates names using “for” loop.

Blurred answer
Students have asked these similar questions
We know that the first file name is stored at index zero in the ArrayList, and the list stores the file names as strings, so could we write the body of listAllFiles along the following lines? System.out.println(files.get(0)); System.out.println(files.get(1)); System.out.println(files.get(2)); etc. How many println statements would be required to complete the method?
Implement the Plates class buildMap function so that it populates the HashMap with the state abbreviations as keys and the counts of how many each appear in the file as values. Sometimes, the parking attendant will add special notation to help her remember something about a specific entry. There are just non alphabetic characters that she adds to the state - your program should ignore these characters so that an entry like NY* still counts toward the NY plate count. She is also very inconsistent with how she enters the plates. Sometimes she uses upper case, sometimes lowercase, and sometimes she even uses a mix. Be sure to account for this in your program.  Only add information for plates in New England (Maine, New Hampshire, Vermont, Massachusetts, Rhode Island, and Connecticut). Plates.java import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set;   public class Plates {     private Map<String, Integer> plateMap;…
Write a program that reads the following txt file using “with open file as f” method, converts each line to a list using the split method with ‘’, as the separator, reverses the order in each list, and writes a new txt file where each line is a list. Nothing in your program should be hard coded, meaning, your program should work properly with other txt files, with different number of lines, elements, and content. The existing txt file: 1,4,3,2,5 8,6,7 C,D,B,A E,F,H,I,J,G The created txt file: [‘5’, ‘2’, ‘3’, ‘4’, ‘1’] [‘7’, ‘6’, ‘8’] [‘A’, ‘B’, ‘D’, ‘C’} [‘G’, ‘J’, ‘I’, ‘H’, ‘F’, ‘E’]   Need code in python
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