Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

Question

Write a program that opens a file for read, reads the data in from the file and calculates the sum of the row values. The data is all integers with 7 values per line, and 10 lines of data in the file. The program must use two functions, one to open the file, and another to output and calculate the sum of the row values. All data must be read into a two dimensional array first, then the data is output and the sum calculated. The data should be printed out by row, along with the sum of the row values. Prototypes

void rowSumCalculator( int myArray[][10], int rowCount, int colCount );

Function rowSumCalculator( ) writes out the data in the array and the sum of the values in the row.

void openFile( ifstream& infile, string prompt );

Function openFile should print the prompt out to the user, read in the filename and open the file. If the file does not open, an error is written to the display, and the user prompted again. The function does not return until a file have been opened.

Example Output

Enter file to process: wksht19_data.txt

1 2 3 4 5 6 7 8 9 10 = 55

10 11 12 13 14 15 16 17 18 19 = 145

10 10 10 10 10 10 10 10 10 10 = 100

0 0 0 0 0 0 0 0 0 0 = 0

23 14 25 22 23 11 33 33 33 12 = 229

2 14 2 22 3 11 3 33 3 12 = 105

3 4 5 22 3 1 3 3 3 12 = 59

 ./a.out

Enter file to process: data.txt

Error-"data.txt" did not open

Enter file to process:

 

 

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
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
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education