Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Implement a function wordCount, which reads a text file, and returns the
number of words in the file.
You can assume the file only contains the
alphabet characters and the space character.
However there may be more
than one space character between two words, so “abc abc” and “abc abc”,
for example, are both two words.
int wordCount ( const char * filename ) {
}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 3 images
Knowledge Booster
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
- Task 1: Find the longest word Implement the function findLongestWord that takes as an argument an array of words and returns the longest one. If there are 2 with the same length, it should return the first occurrence. Write the JS code in a separate file. You can use the following array to test your solution: var words = ['mystery', 'brother', 'aviator', 'crocodile', 'pearl', 'orchard', 'crackpott'];arrow_forwardWrite a function that reads all the numbers from a file into an array. The file is already open and there is no bad data in the file. The data is one number per line and the file has an unknown number of lines of data. Assume that the array is large enough to hold all the data. The data should be stored in the array starting at the first element. Prototype void readData( ifstream& iFile, double numbers[ ], int& count); iFile - already open ifstream numbers[ ] - array to store data count - the number of values read and must be set by the function before returning.arrow_forwardIn C Language Not Like This #include void histogram(int counter[][1]) { int i,j,k; printf("\nHistogram of alphabets in the given file\n"); for(k=97,i=0;iarrow_forward
- in C++ Write a short program to open a file called 'books.txt', read its contents into memory, and write them back out to the end of 'books.txt'. Words beginning with 'd' should be left out (not written out).arrow_forwardIN JAVA - OOP Input File----------employee.csv - employee number, last name, first name, middle name, rate trans.csv - employee number, in, out Output File-----------comptrans.csv - employee number, total hours, overtime, pay 1. Open the two input files for reading. Use the statement below to convert each line read to an array: String[] objEmployee = strLine.split(",") 2. Compute for the following: total hours = out - in overtime = total hours - 8 pay = total hours * (rate + 15%) 3. Write to the output file only those employees with transaction and display the following on screen: Employee number Full name in out total overtime pay --------------- -------------------------- --- --- ----- -------- --- xxxxxx last, first middle initialarrow_forwardWrite a Program in CWrite a c program that counts the number of words and characters in a file. The program should do the following: Asks the user to input the name of the file to be opened. Display the contents of the file. Counts and displays the number of words and characters in a file. Exclude the spaces in the character count. Create a new file named “<inputted_file_name>_wordcharct.txt”, e.g. if the file name inputted in part a is “test.txt” then the file created should be named “test_wordcharct.txt”. Store the displayed information in this file Expected output: Sample 1: Input the file name to be opened: test.txtThe content of the file “test.txt” are: test line 1 test line 2 test line 3 test line 4 -----End of File---- The number of words in the file “test.txt” are: 12 The number of characters in the file “test.txt” are: 36The file “test_wordcharct.txt” containing the results was created successfully! Sample 2: (use this one in creating the program) Input the file…arrow_forward
- The objective of this problem is to show that you can write a program that reads a text file and uses string methods to manipulate the text. File cart.txt contains shopping cart type data from golfsmith.com representing the gifts you have purchased for your dad for this past Fathers Day. Good for you. You have been very generous! The first item in each row of the file is the part number, the second the quantity, the third the price and the fourth the description. Your program will read the file line by line and compute the total cost of all of the items in the list. You will then display a message that looks like this, assuming the cost of each item adds up to 168.42: Here's what your output should look like: The total price for the awesome Fathers Day gifts you bought is $168.42. The shopping cart can be found here: cart.txt. Right click on the link and save the file to the folder where you have your Python files.arrow_forwardComputer Science C++ Create a text file "input.txt" with a certain amount of integers (you decide how many). Write a program that reads these numbers from the file, adds them, and when you have reached the end of the file, calculates the average of these numbers. Print a message and the average to the console. Code this program twice, demonstrating the two methods to detect the end of the file, part A: reading a value from Instream and storing it (boolean expression) in the while loop part B: using the eof() member functionarrow_forwardCreate a file named minesweeper.pyCreate a function that takes a grid of # and -, where each hash (#) represents amine and each dash (-) represents a mine-free spot.Return a grid, where each dash is replaced by a digit, indicating the number ofmines immediately adjacent to the spot i.e. (horizontally, vertically, anddiagonally).Example of an input:[ ["-", "-", "-", "#", "#"],["-", "#", "-", "-", "-"],["-", "-", "#", "-", "-"],["-", "#", "#", "-", "-"],["-", "-", "-", "-", "-"] ]Example of the expected output:[ ["1", "1", "2", "#", "#"],["1", "#", "3", "3", "2"],["2", "4", "#", "2", "0"],["1", "#", "#", "2", "0"],["1", "2", "2", "1", "0"] ]arrow_forward
- Write a program that displays the number of goals scored by players during the next World Cup in Brazil. • The program should prompt the user to enter the number of players they wish to display. If an invalid entry is inputNTED, the program should re-prompt for the number. • Create an array of strings to store the appropriate number of names as entered by the user • Create an array to store each players tally of goals The user is prompted to enter the name of the player and the player’s goal tally (re-prompt in case of an exception, and also if the player has a goal tally of less than zero) • These values are stored respectively into the array of names and goals for each player. • These details are then displayed on the screenarrow_forwardI need to modify this code to be able to read from a file and write into a file. The program is working as it should but I need an example of how to change my input and accept a file instead.arrow_forwardcan you do it pythonarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education