The text file babynames2012.txt, which is included in the source code for this book and is available online from the book’s website, contains a list of the 1000 most popular boy and girl names in the United States for the year 2012 as compiled by the Social Security Administration.
This is a space-delimited file of 1000 entries in which the rank is listed first, followed by the corresponding boy name and girl name. The most popular names are listed first and the least popular names are listed last. For example, the file begins with
1 Jacob Sophia 2 Mason Emma 3 Ethan Isabella |
This indicates that Jacob is the most popular boy name and Sophia is the most popular girl name. Mason is the second most popular boy name and Emma is the second most popular girl name.
Write a
For example, if the user enters the name “Justice,” then the program should output:
Justice is ranked 519 in popularity among boys. Justice is ranked 518 in popularity among girls. |
If the user enters the name “Walter,” then the program should output:
Walter is ranked 376 in popularity among boys. Walter is not ranked among the top 1000 girl names. |
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
C++ How to Program (10th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Database Concepts (8th Edition)
Starting Out with Python (4th Edition)
- The attached file, CommonFemaleNames.txt, contains the top 1000 female names in the United States. The format is integer string where the integer is the popularity number (1 is most popular) and string is a female first name. The program is to read the list of names and create an array of objects. It then sorts the array in alphabetical order. The user enters a name, which the program searches for and then reports how common that name is. The program is to use two different search algorithms, a linear search and a binary search. It reports on how many microseconds it takes to find the name using each method. Requirements 1. Each name and popularity number must be stored in a separate object. 2. The names on the list are all uppercase, but the program must find the name even if it is entered in lower case. Do this by converting the entered name to all caps. 3. It must give an appropriate message if the name entered is not on the list. 4. Both a linear and a binary search are…arrow_forwardFrames Unlimited is a wholesaler that specializes in picture frames. The company stores its product information (each item’s number, name, size and price) in a sequential access file named pictureFrame.txt. You need to create a report using the pictureFrame.txt sequential access file. The report should contain a list of all picture frames with a size of 5×7. The report will be saved to another sequential access file named pictureFrame57.txt. Your first step is to ____. a. determine whether the pictureFrame.txt file exists b. declare a StreamReader variable for the input file c. open the pictureFrame.txt file for input using the OpenText method d. open the pictureFrame57.txt file for output using the CreateText methodarrow_forwardIn the student sample program files for this chapter, you will find a text file namedGasPrices.txt. The file contains the weekly average prices for a gallon of gas in the UnitedStates, beginning on April 5th, 1993, and ending on August 26th, 2013. Figure 8-7 shows anexample of the first few lines of the file’s contents:Figure 8-7 The GasPrices.txt fileDescriptionEach line in the file contains the average price for a gallon of gas on a specific date. Each line isformatted in the following way:MM-DD-YYYY:PriceMM is the two-digit month, DD is the two-digit day, and YYYY is the four-digit year. Price is theaverage price per gallon of gas on the specified date.For this assignment, you are to write one or more programs that read the contents of the file andperform the following calculations:Average Price Per Year: Calculate the average price of gas per year, for each year in thefile. (The file’s data starts in April of 1993, and it ends in August 2013. Use the data that ispresent for the…arrow_forward
- Chapter 7 - Programming Challenge 15 15. World Series Champions If you have downloaded this book’s source code (the companion Web site is available at www.pearsonhighered.com/gaddis), you will find a file named WorldSeriesWinners.txt. This file contains a chronological list of the winning teams in the World Series from 1903 through 2009. (The first line in the file is the name of the team that won in 1903, and the last line is the name of the team that won in 2009. Note that the World Series was not played in 1904 or 1994, so those years are skipped in the file.) Write a program that lets the user enter the name of a team, and then displays the number of times that team has won the World Series in the time period from 1903 through 2009. Tip: Read the contents of the WorldSeriesWinners.txt file into an ArrayList. When the user enters the name of a team, the program should step through the ArrayList, counting the number of times the selected team appears You only need to submit the…arrow_forwardhelparrow_forwardA Personal Fitness Tracker is a wearable device that tracks your physical activity, calories burned, heart rate, sleeping patterns, and so on. One common physical activity that most of these devices track is the number of steps you take each day. The steps.txt file contains the number of steps a person has taken each day for a year. There are 365 lines in the file, and each line contains the number of steps taken during a day. (The first line is the number of steps taken on January 1st, the second line is the number of steps taken on January 2nd, and so forth.) Write a program that reads the file, then displays the average number of steps taken for each month. (The data is from a year that was not a leap year, so February has 28 days.) You don't need to see the file , Just write a code using the "file" like this def main(): with open("steps.txt", "r") as file:arrow_forward
- The attached file, CommonFemaleNames.txt, contains the top 1000 female names in the United States. The format is integer stringwhere the integeris the popularity number (1 is most popular) and stringis a female first name. The program is to read the list of names and create an array of objects. It then sorts the array in alphabetical order. The user entersa name, which the program searches for and then reports how common that name is. The program isto use two different search algorithms, a linear search and a binary search. It reports on how many microseconds it takes to find the name using each method. Requirements 1.Each name and popularity number must be stored in a separate object. 2.The names on the list are all uppercase, but the program must find the name even if it is entered in lower case. Do this by converting the entered name to all caps. 3.It must give an appropriate message if the name entered is not on the list. 4.Both a linear and a binary search are required, for each…arrow_forwardPYTHON CODE Using Artists.csv (link below), write a query that returns all lines that are female artists only, with begin date greater than 1950 but no greater than 2000 Write a query that will return all lines of British Male artists, who's first names starts with the letter ‘A’ and has an end date earlier than 1990 Write a query that will write to a file all lines that have Japanese Artists who’s difference of end date and begin date exceeds 100 years. I.e. if artist begins in 1900 and ends in 2005, then they would be included in the output (2005-1900 = 105 years) Write a query that will write and find to a file the artist who’s been at the Museum the longest (the widest gap between Begin Date and End Date) Artists.csv: https://media.githubusercontent.com/media/MuseumofModernArt/collection/master/Artists.csvarrow_forwardIn Python Write a program that reads movie data from a CSV (comma separated values) file and output the data in a formatted table. The program first reads the name of the CSV file from the user. The program then reads the CSV file and outputs the contents according to the following requirements: Each row contains the title, rating, and all showtimes of a unique movie. A space is placed before and after each vertical separator ('|') in each row. Column 1 displays the movie titles and is left justified with a minimum of 44 characters. If the movie title has more than 44 characters, output the first 44 characters only. Column 2 displays the movie ratings and is right justified with a minimum of 5 characters. Column 3 displays all the showtimes of the same movie, separated by a space. Each row of the CSV file contains the showtime, title, and rating of a movie. Assume data of the same movie are grouped in consecutive rows. Ex: If the input of the program is: movies.csv and the contents…arrow_forward
- In the attached city list.txt file, the names of the provinces in Turkey are given in a single line according to the format given in Figure 1. In the application you will write, write the city names read from this file into the license plate list.txt file in the format shown in Figure 2. In more descriptive terms, citylist.txt is a file given to you. license plate list.txt is the file you will get with your code. city list: Adana, Adıyaman, Afyon, Ağrı, Amasya, Ankara, Antalya, Artvin, Aydın, Balıkesir, Bilecik, Bingöl, Bitlis, Bolu, Burdur, Bursa, Çanakkale, Çankırı, Çorum, Denizli, Diyarbakır, Edirne, Elazığ, Erzincan, Erzurum, Eskişehir, Gaziantep, Giresun, Gümüşhane, Hakkari, Hatay, Isparta, İçel (Mersin), İstanbul, İzmir, Kars, Kastamonu, Kayseri, Kırklareli, Kırşehir, Kocaeli, Konya, Kütahya, Malatya, Manisa, Kahramanmaraş, Mardin, Muğla, Muş, Nevşehir, Niğde, Ordu, Rize, Sakarya, Samsun, Siirt, Sinop, Sivas, Tekirdağ, Tokat, Trabzon, Tunceli, Şanlıurfa, Uşak, Van, Yozgat,…arrow_forwardO kgeme: ot Co htioseeningodmataorkconlaundh Readng r Excel File I/O The attached Distances xlsx file contains a spreadsheet with the pairwise distances in mies of the top 100 US cities by population. A preview of the spreadsheet is shown below. The first row and first column contain the city names using the following format: city name comma space capitalized state abbreviation, e.g, Nashville, TN. Note that the very first cell of the spresheet, A1, is blank. Write a function called get_distance that accepts two character vector inputs representing the names of two cities. The functian returns the distance between them as an output argument called distance. For example, the cali get_distance('Seattle, WA', Miami, FL') should return 3723. If one ar both of the specified cities are not in the file, the function returns 1. Your function should load the data only once. File VO is a time consuming operation. Loading the date multiple times is will likely cause a time-out error when…arrow_forwardEach line of a hockey file contains a four-digit year, a team name, and a two-digit number of wins.Here is one such file, hockey.txt:2003maple leafs452020maple leafs351995senators181996maple leafs302000senators482012canadiens48The first line of the file, for example, says that in 2003 (year), the maple leafs (team name) had 45 wins.Write a function that takes an open hockey file and returns a list of tuples,where each tuple refers to a team name and that team's maximum number of wins in any year.Here is a sample call of the function on hockey.txt:>>> teams_and_most_wins(open('hockey.txt'))[('maple leafs', 45), ('senators', 48), ('canadiens', 48)]"""from typing import TextIOdef teams_and_most_wins(f: TextIO) -> list[tuple[str, int]]:'''f is an open hockey file.Each year has 4 digits and each number of wins has 2 digits.Return a list of tuples where each tuple storesa team name and that team's maximum number of wins in any year.Every team should appear in exactly one of the…arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning