Starting Out with C++ from Control Structures to Objects (8th Edition)
8th Edition
ISBN: 9780133769395
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 12.10, Problem 12.15CP
Describe the mode that each of the following statements causes a file to be opened in:
file.open(“info.dat”, ios::in | ios::out);
file.open(“info.dat”, ios::in | ios::app);
file.open(“info.dat”, ios::in | ios::out | ios::ate);
file.open(“info.dat”, ios::in | ios::out | ios: :binary);
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
A student wants to write into a file called myfile, without deleting its existing content. Which one of the following functions should he or she use?
f = open('myfile', 'r')
f = open('myfile', 'w+b')
f = open('myfile', '+')
f = open('myfile', 'a')
2. File handling is an important part of any application. Assume that, you are asked to
build an application to find the harmonic mean in a file. Assume that you have to read
the file of "Filel.txt" and print the harmonic mean of each row to an output file
"File2.txt". All of the data in the "File1.txt" is comma separated. In file1.txt you are
given the name of the data set in first place, then you are given the data list. All of them
are comma separated. Your task is to compute the harmonic mean from the given file
| for each dataset. The file may contain more than 1000 rows. Write your code by
following the requirements.
File2.txt
harmonic mean of Datal is 3.50
harmonic mean of Data2 is 3.43
harmonic mean of Data3 is 3.50
File1.txt
Data1, 3, 4, 4, 3, 3.7, 4, 3.3, 1
Data2, 3, 4, 3.7, 3, 3.7, 4, 3, 1
Data3, 3, 4, 4, 3, 3.7, 4, 3, 2
Data4, 3, 4, 4, 3, 3.7, 4, 3.3, 2
Design a JAVA application that can perform the task with the given scenario.
harmonic mean of Data4 is 3.49
Using Java, Write an interactive console application for an employee management service. The user can enter the following options for the apps
1-List all employees, sorted by Name.
2-Hire a new employee (add to list)
3-show the lowest salary and highest salary and average of the salaries
0-exit -
At the beginning of the application, data will be read from a text file.
- And at the end of it when user chooses 0, data will be saved to the same file.
- The date format needs to be YYYY-MM-DD and The fields needs to be separated by semicolon(;)
Example of data in the text file : Alice P.;2012-09-22;Shoes;40
Emma W.;2016-07-07;Furniture;30
Eva;2021-08-08;Pizza;50
EmployeeSchedule class has the following attributes
private String name;
private String department;
private Date dateHired;
private double hourSalary;
name : between 2-50 characters and not permitted to have ;^?@!~*
department : between 2-50 characters and not permitted to have ;^?@!~*
dateHired : between 1900 and 2100 salary :…
Chapter 12 Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
Ch. 12.1 - Which file access flag would you use if you want...Ch. 12.1 - Prob. 12.2CPCh. 12.1 - Assuming diskInfo is an fstream object, write a...Ch. 12.1 - Assuming diskInfo is an fstream object, write a...Ch. 12.1 - Assuming diskInfo is an fstream object, write a...Ch. 12.1 - Write a statement that defines an fstream object...Ch. 12.5 - Assume the file input.txt contains the following...Ch. 12.5 - Describe the difference between reading a file...Ch. 12.5 - What will be stored in the file out.txt after the...Ch. 12.10 - Describe the difference between the seekg and the...
Ch. 12.10 - Describe the difference between the tellg and the...Ch. 12.10 - Describe the meaning of the following file access...Ch. 12.10 - What is the number of the first byte in a file?Ch. 12.10 - Briefly describe what each of the following...Ch. 12.10 - Describe the mode that each of the following...Ch. 12 - What capability does the fstream data type provide...Ch. 12 - Which file access flag do you use to open a file...Ch. 12 - Assume the file data.txt already exists, and the...Ch. 12 - How do you combine multiple file access flags when...Ch. 12 - Should file stream objects be passed to functions...Ch. 12 - Under what circumstances is a file stream objects...Ch. 12 - Under what circumstances is a file stream objects...Ch. 12 - Under what circumstances is a file stream objects...Ch. 12 - How do you read the contents of a text file that...Ch. 12 - What arguments do you pass to a file stream...Ch. 12 - What arguments do you pass to a file stream...Ch. 12 - Prob. 12RQECh. 12 - Prob. 13RQECh. 12 - How do you get the byte number of a files current...Ch. 12 - If a program has read to the end of a file, what...Ch. 12 - How do you determine the number of bytes that a...Ch. 12 - How do you rewind a sequential-access file?Ch. 12 - The _____ file stream data type is for output...Ch. 12 - If a file fails to open, the file stream object...Ch. 12 - The same formatting techniques used with...Ch. 12 - The _____ function reads a line of text from a...Ch. 12 - The ____________ member function reads a single...Ch. 12 - The ________member function writes a single...Ch. 12 - Prob. 24RQECh. 12 - __________ files contain data formatted as...Ch. 12 - Prob. 26RQECh. 12 - Prob. 27RQECh. 12 - The ___________ member function writes raw binary...Ch. 12 - The __________ member function reads raw binary...Ch. 12 - Prob. 30RQECh. 12 - In ___________ file access, the contents of the...Ch. 12 - In __________ file access, the contents of a file...Ch. 12 - The _____________ member function moves a files...Ch. 12 - The ___________ member function moves a files...Ch. 12 - The __________ member function returns a files...Ch. 12 - The ___________ member function returns a files...Ch. 12 - The __________ mode flag causes an offset to be...Ch. 12 - The __________ mode flag causes an offset to be...Ch. 12 - The ________ mode flag causes an offset to be...Ch. 12 - A negative offset causes the files read or write...Ch. 12 - Write a statement that defines a file stream...Ch. 12 - Write two statements that use a file stream object...Ch. 12 - Write two statements that use a file stream object...Ch. 12 - Write two statements that use a file stream object...Ch. 12 - Write a program segment that defines a file stream...Ch. 12 - Write code that opens the file data.txt for both...Ch. 12 - Write code that determines the number of bytes...Ch. 12 - The infoFile file stream object is used to...Ch. 12 - T F Different operating systems have different...Ch. 12 - T F fstream objects are only capable of performing...Ch. 12 - T F ofstream objects, by default, delete the...Ch. 12 - T F ifstream objects, by default, create a file if...Ch. 12 - T F Several file access flags may be joined by...Ch. 12 - T F A file may be opened in the definition of the...Ch. 12 - T F If a file is opened in the definition of the...Ch. 12 - T F A file stream objects fail member function may...Ch. 12 - T F The same output formatting techniques used...Ch. 12 - T F The operator expects data to be delimited by...Ch. 12 - T F The getline member function can be used to...Ch. 12 - T F It is not possible to have more than one file...Ch. 12 - T F Binary files contain unformatted data, not...Ch. 12 - T F Binary is the default mode in which files are...Ch. 12 - T F The tellp member function tells a file stream...Ch. 12 - T F It is possible to open a file for both input...Ch. 12 - fstream file(ios::in | ios::out);...Ch. 12 - ofstream file; file.open (info.dat, ios::tin); if...Ch. 12 - fstream file("info.dat"); if (!file) { cout ...Ch. 12 - fstream dataFile("info.dat", ios:in | ios:binary);...Ch. 12 - Prob. 69RQECh. 12 - fstream dataFi1e("info.dat", ios:in); char...Ch. 12 - Prob. 71RQECh. 12 - fstream inFile("info.dat", ios:in); int x;...Ch. 12 - File Head Program Write a program that asks the...Ch. 12 - File Display Program Write a program that asks the...Ch. 12 - Punch Line Write a program that reads and prints a...Ch. 12 - Tail Program Write a program that asks the user...Ch. 12 - Line Numbers (This assignment could be done as a...Ch. 12 - String Search Write a program that asks the user...Ch. 12 - Sentence Filter Write a program that asks the user...Ch. 12 - Array/File Functions Write a function named...Ch. 12 - File Encryption Filter File encryption is the...Ch. 12 - File Decryption Filter Write a program that...Ch. 12 - Prob. 11PCCh. 12 - Prob. 12PCCh. 12 - Inventory Program Write a program that uses a...Ch. 12 - Inventory Screen Report Write a program that reads...Ch. 12 - Average Number of Words If you have downloaded...Ch. 12 - Customer Accounts This program should be designed...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What is the difference between overriding a superclass method and overloading a superclass method?
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Software Sales Software companies often offer their customers the option to lease the software yearly or purcha...
Starting Out With Visual Basic (8th Edition)
It has been suggested that the control software for a radiation therapy machine, used to treat patients with ca...
Software Engineering (10th Edition)
A(n) __________ loop tests its condition before performing an iteration. a. preemptive b. pretest c. infinite d...
Starting out with Visual C# (4th Edition)
These are words or names that are used to identify storage locations in memory and parts of the program that ar...
Starting Out with Java: From Control Structures through Objects (6th Edition)
Consider the following type definition: struct ShoeType { char style; double price; }; Given this structure typ...
Problem Solving with C++ (10th Edition)
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
- Q1: Write a Python program that prompt user to enter at least five entries: 1. Each entry requires two entities: Name (first, last) and Final Score (between 0 and 100) 2. saves the values in a text file 3. calculates the average for Final Score for all the entries written into the file 4. reads that text file and displays its contents on the command prompt including the score average. Write a Python program that prompts the user to search for a string( first and last name) from the file created in Q1. The program displays the name and the final score for that entry if that name was in the file.arrow_forwardCreate an application that writes a series of random numbers to a file. Each random number should be in the range of 1 through 100. The application should let the user specify how many random numbers the file will hold and should use a SaveFileDialog control to let the user specify the file's name and address.arrow_forwardMusic App 1. practise file I/O and exception handling; 2. practise String processing. Aim: Task: Create a Java application that transcripts a simple song score sheet. The program asks user for filename of a text file that contains a simple song score sheet in this format: Sample song score sheet 1, song1.txt: #simple song with assumed time signature = 4 d1mls202s 1mld2o2 d1rimlfls 301s1f1m1rld4 Lines beginning with a hash #' is a comment line. A song contains one or more lines of musical notes, d, r, m, f, s, l, tand also o meaning "Off" or rest. Each single character note is followed by a single digit integer in [1 – 4], denoting the duration of the note in number of beats. After transcription, the program outputs the melody on the screen as well as to another text file: Melody output 1, on screen AND in melody_song1.txt: #simple song with assumed time signature Do Me So- Off- So Me Do Re Me Fa| So-- Off = 4 Do- Off- | So Fa Me Re Do--- | The default time signature is 4 beats per…arrow_forward
- Create a program named FileComparison that compares two files. First, use a text editor such as Notepad to save your favorite movie quote. Next, copy the file contents, and paste them into a word-processing program such as Word. Then, write the file-comparison application that displays the sizes of the two files as well as the ratio of their sizes to each other. To discover a files size, you can create a System. 10. Filelnfo object using statements such as the following, where FILE_NAME is a string that contains the name of the file, and size has been declared as an integer: FileInfo fileInfo = new FileInfo(FILE_NAME); size = fileInfo.Length;arrow_forwardEach of the following files in the Chapter.10 folder of your downloadable student files has syntax and/or logical errors. In each case, determine the problem and fix the program. After you correct the errors, save each file using the same filename preceded with Fixed. For example, DebugTen01.cs will become FixedDebugTen01 .cs. a. DebugTen01.cs b. DebugTen02.cs c. DebugTen03.cs d. DebugTen04.csarrow_forwardIn Chapter 11, you created the most recent version of the MarshallsRevenue program, which prompts the user for customer data for scheduled mural painting. Now, save all the entered data to a file that is closed when data entry is complete and then reopened and read in, allowing the user to view lists of customer orders for mural types.arrow_forward
- Each of the following files in the Chapter.05 folder of your downloadable student files has syntax and/or logical errors. In each case, determine the problem, and fix the program. After you correct the errors, save each file using the same filename preceded with Fixed. For example, save DebugFive1.cs as FixedDebugFive1 .cs. a. DebugFive1.cs b. DebugFive2.cs c. DebugFive3.cs d. DebugFive4.csarrow_forwardA file has r = 20, 000 STUDENT records of fixed length. Each record has the following fields: NAME (30 bytes), SSN (9 bytes), ADRESS(40 bytes), PHONE(9 bytes), BIRTHDATE (8 bytes), SEX(1 byte), CLASSCODE( 4 bytes, integer) MAJORDEPTCODE(4 bytes), MINORDEPTCODE(4 bytes), and DEGREEPROGRAM( 3 bytes). An additional byte is used as a deletion marker. Block size B = 512 bytes. a) Calculate the blocking factor bfr (=floor(B/R), where R is the record size) and number of file blocks b, assuming unspanned organization (a record can’t be split across blocks). b) Suppose only 80% of the STUDENT records have a value for PHONE, 85% for MAJORDEPTCODE, 15% for MINORDEPTCODE, and 90% for DEGREEPROGRAM. We use a variable-length record file. Each record has a 1-byte field type for each field in the record, plus the 1-byte deletion marker and a 1-byte end-of-record marker. Suppose that we use a spanned record organization, where each block has a 5-byte pointer to the next block (this space is not used…arrow_forwardQuestion 5 Identify the correct syntax used to write to a text file. file open('My_data.txt', 'w') file.write(100) file = open('My_data.txt', 'a') file.write(['hello', 'hi', 'hey']) file open('My_data.txt', 'w') file.write('This file contains data') file = open('My_data.txt', 'w') file.write([100, 200, 300j)arrow_forward
- Write a program that creates the following three files; dataplus.txt dataminus.txt zeros.txt The program should read each line of the data.txt file and perform the following; If the line contains a positive number, that number should be written to the dataplus.txt file If the line contains a negative number, that number should be written to the dataminus.txt file If the line contains the value 0, do not write the value to a file. Instead, keep a count of the number of times 0 is read from the data.txt file After all the lines have been read from the data.txt file, the program should write the count of zeros to the zeros.txt file. The code is below does not work:arrow_forwardchown bob:bin file.txt Which of the following statements are true ? ( Choose two.) a. This changes the user owner of file.txt to bin. b. This changes the user owner of file.txt to bob. c. This changes the group owner of file.txt to bin d. This changes the group owner of file.txt to bob.arrow_forwardWrite the code in python Create an application that can create, display, search and maintain the book information for a bookstore. Requirements: 1) you need to use functions to write code for each menu item. 2) Information of books will be saved in a file, e.g,, books.txt. 3)User can add any number of books to the booklist. There can be 5 books or 500 books. In order for your program to handle it without any changes in the code, you cannot hardcode the number of books in your program.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
C - File I/O; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=cEfuwpbGi1k;License: Standard YouTube License, CC-BY
file handling functions in c | fprintf, fscanf, fread, fwrite |; Author: Education 4u;https://www.youtube.com/watch?v=aqeXS1bJihA;License: Standard Youtube License