
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++ 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_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
- I 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_forwardExtend the program to display which player has the highest batting average (hits / atBats) and that average. ---------------------- stats.txt file info: Andrus 574 148 Beltre 543 151 Choo 531 146 Fielder 592 182 Odor 405 108 ---------- Program to modify: /* COSC 1437 Activity 3 Baseball Statistics */ #include <iostream> #include <string> #include <fstream> using namespace std; // Structure to hold batting statistics struct Player { string name; int atBats; int hits; }; int main() { ifstream statFile; string playerName; int bats, hits; Player * baseballArray[100]; Player * aPlayer; int numPlayers = 0; statFile.open("stats.txt"); // Continue reading until the end of file while (statFile >> playerName) { statFile >> bats >> hits; // Dynamically create a new Player aPlayer = new Player; aPlayer->name = playerName; aPlayer->atBats = bats; aPlayer->hits = hits; // Store the pointer to the Player struct in the array baseballArray[numPlayers++] =…arrow_forward
- Can you please answer the following question. The program is in JavaScript and must contain readlineSync. Thanks Create a file named reverse.js. Write a program that allows me to enter ten integers. Write code that reverses the array without using the reverse function on the array. Then iterate over the array and display the values from the reversed array.arrow_forwardJava Your program must read a file called personin.txt. Each line of the file will be a person's name, the time they arrived at the professor's office, and the amount of time they want to meet with the professor. These entries will be sorted by the time the person arrived. Your program must then print out a schedule for the day, printing each person's arrival, and printing when each person goes in to meet with the professor. You need to print the events in order of the time they happen. In other words, your output will be sorted by the arrival times and the times the person goes into the professor's office. In your output you need to print out a schedule. In the schedule, new students go to the end of the line. Whenever the professor is free, the professor will either meet with the first person in line, or meet with the first person in line if nobody is waiting. Assume no two people arrive at the same time. You should solve this problem using a stack and a queue. You can only…arrow_forwardIn this assignment, you will create a Java program to search recursively for files in a directory.• The program must take two command line parameters. First parameter is the folder to search for. Thesecond parameter is the filename to look for, which may only be a partial name.• If incorrect number of parameters are given, your program should print an error message and show thecorrect format.• Your program must search recursively in the given directory for the files whose name contains the givenfilename. Once a match is found, your program should print the full path of the file, followed by a newline.• You can implement everything in the main class. You need define a recursive method such as:public static search(File sourceFolder, String filename)For each subfolder in sourceFolder, you recursively call the method to search.• A sample run of the program may look like this://The following command line example searches any file with “Assignment” in its name%java FuAssign7.FuAssignment7…arrow_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