C++ for Engineers and Scientists
C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
Question
Book Icon
Chapter 8.2, Problem 5E

a.

Program Plan Intro

Program Plan:

  • Include library files for various operations.
  • Declare object ofofstream.
  • Create a statement to open the write data to the file “employee.dat”.
  • Use if statement with fail() method to check that the entered file name is available or not.
  • int main() function is used to perform all the task.
  • Display the calculated results to the user.

Program Description: The main purpose of the program is to create a text file, “employee.dat” and to write the given data to the file.

b.

Program Plan Intro

Program Plan:

  • Include library files for various operations.
  • Declare objects ofifstream and ofstream.
  • Declare required variable.
  • Create two statements to open “employee.dat” and “employee.bak” file.
  • Use if statement with fail() method to check that the entered file name is available or not.
  • int main() function is used to perform all the task.
  • Display the calculated results to the user.

Program Description: The main purpose of the program is to modify the program code of part (a) so that the program code can create a duplicate copy of the text file with the name “employee.bak”, that contains all the data of “employee.dat” file.

c.

Program Plan Intro

Program Plan:

  • Include library files for various operations.
  • Declare objects ofifstream and ofstream.
  • Declare required variable.
  • Read file names from the user.
  • Create two statements to open “employee.dat” and “employee.bak” file.
  • Use if statement with fail() method to check that the entered file name is available or not.
  • int main() function is used to perform all the task.
  • Display the calculated results to the user.

Program Description: The main purpose of the program is to modify the program code of part (b)so that the program code will read the name of the original and duplicate file from the user, creates a duplicate copy of the text file with name “employee.bak”, that contains all the data of “employee.dat” file.

d.

Program Plan Intro

To find the better method for accepting the original and duplicate filenames in the program.

Blurred answer
Students have asked these similar questions
(C++ Language) Create a function that writes to a file named Inventy.txt the information of 8 items. Ask the user for the item's name, the item's quantity in storage, and the item's price and write it to the file. Create a function that reads the file and items' quantity and price to two different arrays. Create a function that computes the subtotal of each item. Implement all functions inside the main program and the computed value should be displayed with the item's name.
(C Language) Given a set of text files containing synonyms for different words, complete the main program to output the synonyms for a specific word. Each text file contains synonyms for the word specified in the file’s name, and the synonyms within the file are grouped according to the synonyms' first letters, separated by an '*'. The program reads a word and a letter from the user and opens the text file associated with the input word. The program then stores the contents of the text file into a two-dimensional array of char* predefined in the program. Finally the program searches the array and outputs all the synonyms that begin with the input letter, one synonym per line, or a message if no synonyms that begin with the input letter are found.
Q2) Write a C++ program to read and write from the file, three numbers (No.1 ,No.2 and No.3) and calculate the max. value using function?
Knowledge Booster
Background pattern image
Similar questions
SEE MORE 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