Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

LAB 5.4 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. 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

_________

// Fill in the input statement that brings in the

// quantity and price of the item.

// Fill in the assignment statement that determines the totalbill.

// Fill in the output statement that prints the total bill,

// with a label, to an output.

return 0;

}

__________________________________________________________________________

Exercise 1: Notice that this is an altered version of Lab 3.1. This program gets the information form 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:

image text in transcribed

Exercise 2: Fill in the blank and the statements that will read the data from the file and print the following to bill.out:

image text in transcribed

transaction - Notepad File Edit Format View Help 10.98

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions

Question

Will you be able to pay your bills?

Answered: 1 week ago

Question

What factors in Nooyis Five C model facilitate employee trust?

Answered: 1 week ago