Implement a program that counts the number of single-letter words in a text file. Input and...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Implement a program that counts the number of single-letter words in a text file. Input and output: Your program should input the name of a text file, and print the number of single-letter words in that file. The file name is a string, the length of which is between 1 and 60. The file contains between 1 and 1,000 lines, each of which is between 1 and 60 characters long. The characters in the file include letters, spaces, and line breaks. The file does not include digits or punctuation marks, and it also does not include blank lines. A single-letter word in that file may be a letter surrounded by spaces; a letter in the beginning of a line followed by a space; a letter in the end of a line preceded by a space; or a single-letter line. In other words, it is a letter that does not have another letter next to it. Example file: We r aliens I We talk in a strange language Wer friendly Example output: Command Prompt C:\>java Honevorkia Enter nane of the input file: nessage.txt The message includes 3 single-letter words C:\> Implement a program that counts the number of single-letter words in a text file. Input and output: Your program should input the name of a text file, and print the number of single-letter words in that file. The file name is a string, the length of which is between 1 and 60. The file contains between 1 and 1,000 lines, each of which is between 1 and 60 characters long. The characters in the file include letters, spaces, and line breaks. The file does not include digits or punctuation marks, and it also does not include blank lines. A single-letter word in that file may be a letter surrounded by spaces; a letter in the beginning of a line followed by a space; a letter in the end of a line preceded by a space; or a single-letter line. In other words, it is a letter that does not have another letter next to it. Example file: We r aliens I We talk in a strange language Wer friendly Example output: Command Prompt C:\>java Honevorkia Enter nane of the input file: nessage.txt The message includes 3 single-letter words C:\>
Expert Answer:
Answer rating: 100% (QA)
def countsingleletterwordsfilename Counts the number of singleletter words in a text file Args filename The name of the text file Returns The number o... View the full answer
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Posted Date:
Students also viewed these programming questions
-
Your firm has an organisational policy and procedures manual, which all employees use in carrying out their roles. This includes the steps to be taken in the preparation of client tax returns. You...
-
Assignment 5: Hash Table implementation andconcordance There are three parts to this assignment. In the first two parts,you will complete the implementation of a hash map and aconcordance program. In...
-
Consider thedeadlock situation that could occur in the dining-philosophers problem when the philosophers obtain the chopsticks one at a time. Discuss how the four necessary conditions for deadlock...
-
How has the environment shaped Leighton Holdings operations? What do you think might have been the outcome in different economic times? Why?
-
This exercise parallels the machine-purchase decision for the Mendoza Company that is discussed in the body of the chapter. Assume that Mendoza is exploring whether to enter a complementary line of...
-
A proximity probe has a useful frequency range related to what operating parameter?
-
House Corporation has been operating profitably since its creation in 1960. At the beginning of 2016, House acquired a 70 percent ownership in Wilson Company. At the acquisition date, House prepared...
-
The following information is available for Shamrock Company. January 1, 2022 2022 December 31, 2022 Raw materials inventory $18,800 $27,000 Work in process inventory 12,300 15,550 Finished goods...
-
Cherry Cotta makes custom ordered clay pots for residential gardens. Below is cost information regarding its latest job. a. Materials were purchased on account. $18,996 purchased b. A materials...
-
Dividends on investments classified as either trading or available for sale that have been declared as of year-end but have not yet been received should be recognized in income when... A) accrued B)...
-
Assume that a firm uses capital as a fixed factor of production and uses labor as a variable factor. The marginal product of labor at first increases and then decreases with the amount of labor. (a)...
-
Your supermarket is selling 1000 containers of margarine a week at $1.50 each. You know that the price elasticity of demand for margarine is -0.8. You decide to reduce the price by 10%. a. How many...
-
Get a current copy of The Wall Street Journal and find the Dow Jones Country Indexes listing in Section C of the newspaper. Examine the 12-month changes in U.S. dollars for the various national...
-
Kim, a broker appointed with a large life insurance company, is being investigated as part of a larger money laundering investigation. If convicted of money laundering, what does she face?
-
1) Does democracy require equality of income or wealth? Discuss why democracy might make a country more or less egalitarian?
-
Exercise: Solve the system of linear congruences 5x = 1 mod 6, 3x = 2 mod 5, 4r = 5 mod 7.
-
A parking lot charges $3 for the first hour (or part of an hour) and $2 for each succeeding hour (or part), up to a daily maximum of $10. (a) Sketch a graph of the cost of parking at this lot as a...
-
Write a toString method for a binary tree of integers. The method should return "empty" for an empty tree. For a leaf node, it should return the data in the node as a string. For a branch node, it...
-
Javas type int has a limit on how large an integer it can store. This limit can be circumvented by representing an integer as an array of digits. Write an interactive program that adds two integers...
-
Implement a class called StudentAdvanceTicket to represent tickets purchased in advance by students. A student advance ticket is constructed with a ticket number and with the number of days in...
-
An engineering student wanted to know which factors influence the time (in seconds) for his car to go from 0 to 30 to 0 miles per hour. Factor \(A\) was the launch, which was either no wheel spin or...
-
The effect on engine wear of oil viscosity, temperature, and a special additive was tested using a \(2^{3}\) factorial design. Given the following results from the experiment, Interpret the effects...
-
Two machines \(X\) and \(Y\) were used to produce two types of plastic polymers, PPET and PAMI. The polymers were produced using materials BA and PP. The production was run 3 times. The \(y\) values...
Study smarter with the SolutionInn App