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.1, Problem 12.5CP
Assuming diskInfo is an fstream object, write a statement that opens the file payable.txt for both input and output.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
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
Write a statement that defines a file stream object named pets. The object will be used for file input.
Write a statement that defines a file stream object named people. The object will be used for file output.
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
Fill in the blanks in each of the following statements: A relation that has no partial functional dependencies ...
Modern Database Management (12th Edition)
First to One Game This game is meant for two or more players. In the game, each player starts out with 50 point...
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Calories from Fat and Carbohydrates A nutritionist who works for a fitness club helps members by evaluating the...
Starting Out with Python (3rd Edition)
Suppose that the class Pet has a field called name that is of the type String. Write an assignment statement in...
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
What technique was described in this section for finding the classes in a particular problem?
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
A (n) _______operator determines if a specific relationship exists between two values.
Starting Out With Visual Basic (7th 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
- Write a code segment that creates an ofstream object named outfile, opens a file named numbers.txt, and associates it with outfile. The code should then use a loop to write the numbers 1 through 100 to the file before closing it.arrow_forwardO O An object of the fstream class, so what is the default mode to open the file the default mode depends on the compilerarrow_forwardWrite a statement that defines an fstream object named dataFile and opens afile named salesfigures.txt for input. ( Note: The file should be opened withthe definition statement, not an open function call.)arrow_forward
- in pythonarrow_forwardC++: Create a standalone program that performs the tasks below. Start by solving task one and complete that task before starting task 2. Your program should read the files mentioned from the "current working directory". All files are in text format with "\n" at the end of the line. Ifyou wish, you can use pipes and redirects to solve the file reading and printing instead of std : ifstream and std:: ofstream. Inthat case, comment on it in the code along with examples of how the program is used. The file names.txt contains names and social security numbers in the following form. The file contains several people: First Name Last Name YYMMDDNNNN Address bar Your task is to convert the input data into the form: Surname, First name Address bar The output should indicate whether the person is a man or a woman. For example, for a man it may say: Last name, First name [M] Address bar * YYMMDDNNNN: All those registered in Sweden are given a personal identity number as identification. A person…arrow_forwardin c # i need to Write the program FileComparison that compares two files. Two files have been provided for you, Quote.txt and Quote.docx, both containing movie quotes and are located in the /root/sandbox/ directory Note: you will not be able to see the Quote.docx file. Next 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 file’s size, you can create a System.IO.FileInfo 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; Your program's output should look like the following: The size of the Word file is FILE_SIZE and the size of the Notepad file is FILE_SIZE The Notepad file is x% of the size of the Word file I am getting the error Test Case IncompleteFileComparison calculates the difference between the .txt and .docxfiles…arrow_forward
- Given a valid file object, f, which of the following calls will return the entire contents of the file in a scalar x? x = f.readline() x = f.readlines() x = f.read() X = read(f)arrow_forward* The ofstream class then default mode of opening the file are ios::in ios::out O ios::outlios::trunk O ios::inlios::trunc Oarrow_forwardThis Python Lab 9 Lab: Write a file copying program. The program asks for the name of the file to copy from (source file) and the name of the file to copy to (destination file). The program opens the source file for reading and the destination file for writing. As the program reads each line from the source file and it writes the line to the destination file. When every line from the source file has been written to the destination file, it close both files and print “Copy is successful.” In the sample run, “add.py” is the source file and “add-copy.py” is the destination file. Note that both “add-copy.py” is identical to “add.py” because “add-copy.py” is a copy of “add.py”. Sample run: Enter file to copy from: add.py Enter file to copy to : add-copy.py Copy is successful. Source file: add.py print("This program adds two numbers") a = int(input("Enter first number: ")) b = int(input("Enter second number: ")) print(f"{a} + {b} = {a+b}") Destination file:…arrow_forward
- Each of the following programs or program segments has errors. Find as many as you can.65. fstream file(ios::in | ios::out);file.open("info.dat");if (!file){cout << "Could not open file.\n";}66. ofstream file;file.open("info.dat", ios::in);if (file){cout << "Could not open file.\n";}67. fstream file("info.dat");if (!file){cout << "Could not open file.\n";}68. fstream dataFile("info.dat", ios:in | ios:binary);int x = 5;dataFile << x;69. fstream dataFile("info.dat", ios:in);char stuff[81];dataFile.get(stuff);70. fstream dataFile("info.dat", ios:in);char stuff[81] = "abcdefghijklmnopqrstuvwxyz";dataFile.put(stuff);71. fstream dataFile("info.dat", ios:out);struct Date{int month;int day;int year;};Date dt = { 4, 2, 98 };dataFile.write(&dt, sizeof(int));72. fstream inFile("info.dat", ios:in);int x;inFile.seekp(5);inFile >> x;arrow_forwardYou develop a Python application for your school.You need to read and write data to a text file. If the file does not exist, it must be created. If the file has content, the content must be removed.Which code should you use? Group of answer choices C. open(“local_data”, “w+”) D. open(“local_data”, “w”) A. open(“local_data”, “r”) B. open(“local_data”, “r+”arrow_forwardpythonarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
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