Write a program that counts the number of characters, words, and lines in a given file....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program that counts the number of characters, words, and lines in a given file. Whitespace characters' separate words. The followings are required: a. The program should prompt the user to enter file name b. The program should read the file name from keyboard c. Make sure that the data file exists prior to reading it d. The program read the file contents and count the number of characters, words and lines the file has. The following diagram shows a sample of the program when it runs and read file Please enter file to be processed: test Document.txt Does the file exist in the system? YES Processing File test Document.txt 3087 Characters 476 words 83 Lines Write a program that counts the number of characters, words, and lines in a given file. Whitespace characters' separate words. The followings are required: a. The program should prompt the user to enter file name b. The program should read the file name from keyboard c. Make sure that the data file exists prior to reading it d. The program read the file contents and count the number of characters, words and lines the file has. The following diagram shows a sample of the program when it runs and read file Please enter file to be processed: test Document.txt Does the file exist in the system? YES Processing File test Document.txt 3087 Characters 476 words 83 Lines Write a program that counts the number of characters, words, and lines in a given file. Whitespace characters' separate words. The followings are required: a. The program should prompt the user to enter file name b. The program should read the file name from keyboard c. Make sure that the data file exists prior to reading it d. The program read the file contents and count the number of characters, words and lines the file has. The following diagram shows a sample of the program when it runs and read file Please enter file to be processed: test Document.txt Does the file exist in the system? YES Processing File test Document.txt 3087 Characters 476 words 83 Lines
Expert Answer:
Answer rating: 100% (QA)
Answer Certainly Below is a simple Python program that fulfills the specified requirements This prog... View the full answer
Related Book For
Introduction To Java Programming And Data Structures Comprehensive Version
ISBN: 9780136520238
12th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
Firm ABC currently (the beginning of year one) earnings per share equal $9.40 and grow at 3% per year (intrinsic growth rate independent of dividend policy). The company now sees an investment...
-
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...
-
The following are trial balance of Clarissa Amanda Sdn. Bhd. as at 31st December 2021. Debit RM Credit RM Opening stock, 1 Jan 2021 16,000 Purchases 75,000 Sales return 5,000 Carriage inwards 1,500...
-
Suppose the management of the First National Bank of New York decides that it needs to expand its fee-income-generating services. Among the services the bank is considering adding to its service menu...
-
The statement of financial position as at 31 December 20X2 of Zoom Products Ltd included: Trade receivables...............................85,360 The financial statements for the year ended 31...
-
A company reports the following information about its sales and its cost of sales. Each unit of its product sells for $500. Use these data to prepare a scatter diagram. Draw an estimated line of cost...
-
Credit data were collected on a random sample of 25 U.S. cities in a recent year. Following are the average credit scores, the average debt, the average number of late payments, the average...
-
You are promoting a rock concert in your area. Each member of your team will invest $10,000 of his or her hard-earned money in this venture. It is April 1 and the concert is scheduled for June 30....
-
Precision Manufacturing Incorporated (PMI) makes two types of industrial component parts-the EX300 and the TX500. It annually produces 68,000 units of EX300 and 13,300 units of TX500. The company's...
-
1. Demonstrate a sequence of instruction for SIC to set BETA = ALPHA + INCR-1 DELTA = GAMMA + INCR-1 2. Illustrate how the same calculation could be performed on SIC/XE.
-
XBRL GL, or XBRL Global Ledger Taxonomy, is different from XBRL U.S. GAAP because it facilitates a. efficient communication between the firm and external parties. b. efficient communication within a...
-
Unauthorized alteration of records in a database system would impair which of the following components of the CIA (related to security)? a. Confidentiality b. Integrity c. Availability d....
-
The computer-based technique to accumulate and analyze data to learn about a competitor is called a. business intelligence. b. data warehouse. c. digital dashboard. d. XBRL.
-
Which of the following network components is set up to serve as a security measure that prevents unauthorized traffic between different segments of the network? a. Switch b. Router c. Firewall d....
-
Controls that are designed to prevent, detect, or correct errors in transactions as they are processed through a specific subsystem are referred to as a. general controls. b. application controls. c....
-
Which of the following statements about the operation of a corporation is correct? Select one: O a. A corporation receives its charter from a state government. O b. A corporate charter automatically...
-
Recall that Chapter 8 described the binary search algorithm for finding a particular entry in an ordered list. The idea behind binary search is to begin looking in the exact center of the list. If...
-
Rewrite Programming Exercise 15.29 using a thread to control car racing. Compare the program with Programming Exercise 15.29 by setting the delay time to 10 in both the programs. Which one runs the...
-
Write a servlet that displays the student name and the current score, given the SSN and class ID. For each class, a text file is used to store the student name, SSN, and current score. The file is...
-
Define the Triangle2D class that contains: Three points named p1, p2, and p3 of the type MyPoint with getter and setter methods. MyPoint is defined in Programming Exercise 10.4. A no-arg...
-
In the 1136 Tenants case all of the following were factors in the case except a. Violation of federal criminal statutes. b. Due care. c. A clearly written engagement letter. d. Misunderstanding as to...
-
Read the following statements and indicate whether you agree or disagree with each one. Give your reasons for agreement or disagreement. Support your answers with references to applicable cases...
-
A colleague has read about the legal cases with which auditors have been involved in recent years. During a discussion, you consider it beneficial to summarize some highlights of auditors' legal...
Study smarter with the SolutionInn App