LAB 3.5 Reading and Writing to a File Bring in billfile.cpp from the Lab 5 folder. The code is as follows: // This program will read in the quantity of a particular item and its price. // It will then print out the total price. // The input will come from a data file and the output will go to // an output file.   // PLACE YOUR NAME HERE   #include #include using namespace std;   int main() { ifstream dataIn;// defines an input stream for a data file ofstream dataOut;// defines an output stream for an output file int quantity;// contains the amount of items purchased float itemPrice;// contains the price of each item float totalBill; // contains the total bill, i.e. the price of all items   dataIn.open("transaction.dat");// This opens the file.  dataOut.open("bill.out");   // Fill in the appropriate code in the blank below   << setprecision(2) << fixed << showpoint;// formatted output       // Fill in the input statement that brings in the // quantity and price of the item   // Fill in the assignment statement that determines the total bill.   // Fill in the output statement that prints the total bill, with a label, // to an output file   return 0; } Exercise 1: Notice that this is an altered version of Lab 3.1. This program gets the information from a file and places the output to a file. You must create the data file. Your instructor will tell you how to create the data file and where to put it. Create a data file called transaction.dat that has the following information: 22 10.98 Exercise 2: Fill in the blank and the statements that will read the data from the file and print the following to bill.out: The total bill is $241.56

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

LAB 3.5 Reading and Writing to a File
Bring in billfile.cpp from the Lab 5 folder. The code is as follows:

// This program will read in the quantity of a particular item and its price.

// It will then print out the total price.

// The input will come from a data file and the output will go to

// an output file.

 

// PLACE YOUR NAME HERE

 

#include <fstream>

#include <iomanip>

using namespace std;

 

int main()

{

ifstream dataIn;// defines an input stream for a data file

ofstream dataOut;// defines an output stream for an output file

int quantity;// contains the amount of items purchased

float itemPrice;// contains the price of each item

float totalBill; // contains the total bill, i.e. the price of all items

 

dataIn.open("transaction.dat");// This opens the file. 

dataOut.open("bill.out");

 

// Fill in the appropriate code in the blank below

 

<< setprecision(2) << fixed << showpoint;// formatted output

 

 

 

// Fill in the input statement that brings in the

// quantity and price of the item

 

// Fill in the assignment statement that determines the total bill.

 

// Fill in the output statement that prints the total bill, with a label,

// to an output file

 

return 0;

}

Exercise 1: Notice that this is an altered version of Lab 3.1. This program gets
the information from a file and places the output to a file. You must
create the data file. Your instructor will tell you how to create the data file
and where to put it. Create a data file called transaction.dat that has the
following information:
22
10.98
Exercise 2: Fill in the blank and the statements that will read the data from the
file and print the following to bill.out:
The total bill is $241.56

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
File Input and Output Operations
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education