EP MINDTAPV2.0 FOR MALIK'S C++ PROGRAMM
EP MINDTAPV2.0 FOR MALIK'S C++ PROGRAMM
8th Edition
ISBN: 9780357425299
Author: Malik
Publisher: CENGAGE CO
bartleby

Videos

Textbook Question
100%
Book Icon
Chapter 3, Problem 1PE

Consider the following incomplete C++ program:

#include <iostream>

int main()

{

}

  1. Write a statement that includes the header files fstream, string, and iomanip in this program.

  2. Write statements that declare inFile to be an ifstream variable and outFile to be an ofstream variable.

  3. The program will read data from the file inData.txt and write output to the file outData.txt. Write statements to open both of these files, associate inFile with inData.txt, and associate outFile with outData.txt.

  4. Suppose that the file inData.txt contains the following data:

    Giselle Robinson Accounting

    5600 5 30

    450 9

    75 1.5

The first line contains a person's first name, last name, and the department the person works in. In the second line, the first number represents the monthly gross salary, the bonus (as a percent), and the taxes (as a percent). The third line contains the distance traveled and the traveling time. The fourth line contains the number of coffee cups sold and the cost of each coffee cup. Write statements so that after the program executes, the contents of the file outData.txt are as shown below. If necessary, declare additional variables. Your statements should be general enough so that if the content of the input file changes and the program is run again (without editing and recompiling), it outputs the appropriate results.

Name: Giselle Robinson, Department: Accounting

Monthly Gross Salary: $5600.00, Monthly Bonus: 5.00, Taxes: 30.000

Paycheck: $4116.00

Distance Traveled 450.00 miles, Traveling Time: 9.00 hours

Average Speed: 50.00 miles per hour

Number of coffee Cups Sold: 75, Cost: $1.50 per cup

Sales Amount = $112.50

  1. Write statements that close the input and output files.

  2. Write a C++ program that tests the statements in parts a through e.

Blurred answer
Students have asked these similar questions
This is for devc++
This 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:…
Language: C++ Write a program which reads from the standard input the name of a file (e.g., "input.txt"). Your should use C++ streams to create a copy of this file with the name as the original program file name concatenated with "_copy" and then the original extension (e.g., "input_copy.txt"). You can assume that the input will be valid and the necessary input file has a valid content if ex- isting.
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
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