Write a program that first reads in the name of an input file and then reads...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program that first reads in the name of an input file and then reads the input file using the file.readlines() method. The input file contains an unsorted list of number of seasons followed by the corresponding TV show. Your program should put the contents of the input file into a dictionary where the number of seasons are the keys, and a list of TV shows are the values (since multiple shows could have the same number of seasons). Sort the dictionary by key (greatest to least) and output the results to a file named output_keys.txt. Separate multiple TV shows associated with the same key with a semicolon (;), ordering by appearance in the input file. Next, sort the dictionary by values (in reverse alphabetical order), and output the results to a file named output_titles.txt Ex: If the input is: filel.txt and the contents of file1.txt are: 20 Gunsmoke 30 The Simpsons 10 Will & Grace 14 and the contents of file1.txt are: 20 Gunsmoke 30 The Simpsons 10 Will & Grace. 14 Dallas 20 Law & Order 12 Murder, She Wrote the file output_keys.txt should contain: 10: Will & Grace 12: Murder, She Wrote 14: Dallas 20: Gunsmoke; Law & Order 30: The Simpsons and the file output_titles.txt should contain: Dallas Gunsmoke 12: Murder, She Wrote 14: Dallas 20: Gunsmoke; Law & Order 30: The Simpsons and the file output_titles.txt should contain: Dallas Gunsmoke Law & Order Murder, She Wrote The Simpsons Will & Grace Write a program that first reads in the name of an input file and then reads the input file using the file.readlines() method. The input file contains an unsorted list of number of seasons followed by the corresponding TV show. Your program should put the contents of the input file into a dictionary where the number of seasons are the keys, and a list of TV shows are the values (since multiple shows could have the same number of seasons). Sort the dictionary by key (greatest to least) and output the results to a file named output_keys.txt. Separate multiple TV shows associated with the same key with a semicolon (;), ordering by appearance in the input file. Next, sort the dictionary by values (in reverse alphabetical order), and output the results to a file named output_titles.txt Ex: If the input is: filel.txt and the contents of file1.txt are: 20 Gunsmoke 30 The Simpsons 10 Will & Grace 14 and the contents of file1.txt are: 20 Gunsmoke 30 The Simpsons 10 Will & Grace. 14 Dallas 20 Law & Order 12 Murder, She Wrote the file output_keys.txt should contain: 10: Will & Grace 12: Murder, She Wrote 14: Dallas 20: Gunsmoke; Law & Order 30: The Simpsons and the file output_titles.txt should contain: Dallas Gunsmoke 12: Murder, She Wrote 14: Dallas 20: Gunsmoke; Law & Order 30: The Simpsons and the file output_titles.txt should contain: Dallas Gunsmoke Law & Order Murder, She Wrote The Simpsons Will & Grace
Expert Answer:
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
Fergie has the choice between investing in a State of New York bond at 11.2 percent and a Surething Incorporated bond at 14.2 percent. Assuming that both bonds have the same nontax characteristics...
-
In this project, we will write a program that controls a quiz show, much like the many popular TV shows. The program will read in a group of questions and their multiple choice answers, storing them...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
The three courses below represent a polygon. They are consecutive azimuths measured clockwise from North in DMS. Course A to B: 55-35-21 Course B to C: 175-48-19 Course C to A: 293-22-28 Choose the...
-
Choose a particular industry and explain why time is important as a source of customer value within that industry.
-
Daniela Ibarra is a senior analyst in the fixed-income department of a large wealth management firm. Marten Koning is a junior analyst in the same department, and David Lok is a member of the credit...
-
Read about the ZZZZ Best Carpet Cleaning fraud. What schemes did the fraudsters use?
-
Jupiter Company sells goods on January 1 that have a cost of $500,000 to Danone Inc. for $700,000, with payment due in 1 year. The cash price for these goods is $610,000, with payment due in 30 days....
-
Stockton Mineral Operations, Incorporated, (SMO) currently has 475,000 shares of stock outstanding that sell for $80 per share. Assume no market imperfections or tax effects exist. Determine the...
-
In this lab we will be investigating the relationship between the height of a roller coaster and its speed. Suppose we are interested in the question; Does the height of the roller coaster relate to...
-
rk: Homework #3 (chapter Question 26, Instructor-created question ist Ask my instructor HW Score: 79.51%, 38.17 of 48 points Points: 0 of 1 Save Find the interest rate needed for the sinking fund to...
-
Once a planner has established a client's objectives and gathered his or her data, what should the planner do next as part of the estate planning process? Discuss.
-
In Aldous Huxley's "Brave New World" he described a society that looks startlingly like ours: people who live for pleasure and distraction, aided by consciousness altering drugs that keep them happy....
-
1) Identify and elaborate the steps in the strategic brand management process 2) What are the three 3 ways to capture value from customers? 3) Explain the different types of marketing channels mix...
-
How do brand perceptions vary across different customer segments, and how can we tailor our brand messaging to resonate with each segment? Explain in details.
-
ageNOWv2 | Online teach X C Post a new question Paul messaged you X + eAssignment/takeAssignmentMain.do?invoker=&takeAssignmentSession Locator=&inprogress=false On November 10, JumpStart Co. provides...
-
Para la medicin de la innovacin se debe gestionar y en este proceso se incluye el indicador de la documentacin donde un indicadores final es medir el porcentaje de las ventas anuales que se deben a...
-
Write the general quadratic equation y2 - 8y - 4x + 28 = 0 in standard form. Determine the vertex, focus, and directrix of the parabola defined by this equation. Sketch a graph.
-
Write the following method that returns the maximum value in an ArrayList of integers. The method returns null if the list is null or the list size is 0. public static Integer max(ArrayList list)...
-
Write a program that prompts the user to enter two strings and tests whether the second string is a substring of the first string. Suppose the neighboring characters in the string are distinct....
-
Rewrite Listing 5.1 RepeatAdditionQuiz.java to alert the user if an answer is entered again. Hint: use an array list to store answers. Here is a sample run: Listing What is 5 + 9? 12 Wrong answer....
-
Why are Cynthia Cooper and Scott Sullivan significant in detecting financial reporting fraud?
-
Why might management be interested in forensic accounting services?
-
What is a red flag with respect to earnings?
Study smarter with the SolutionInn App