Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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

ID: 3639199 • Letter: #

Question

// 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. 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 totalbill.

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


return 0;
}

Explanation / Answer

Modified Code:

//Modified Code is marked Red

// 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
cout<< setprecision(2) << fixed << showpoint; // formatted output


// Fill in the input statement that brings in the
// quantity and price of the item.

cin>>quantity;

cin>>itemPrice;

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

totalBill = quantity * itemPrice;

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

cout<< "Total Bill: "<<totalBill <<endl;


return 0;
}