//This program will read in the quantity of a particular item and its price. //
ID: 3620691 • Letter: #
Question
//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 ouput will go to an output file.
# include <ifstream> // needed to use files.
# 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; //number of item purchased
double itemPrice; // price of each item
double totalBill; // total price of all items
dataIn.open ("transaction.dat"); //These 2 statements open file.
dataOut.open("bill.out");
--- ------setprecision(2)<< fixed<< showpoint; // format output in the output file
// write an input statement that brings the quantity and price
// of the item in form of data file. // write an assignment statement that places the correct value in totalbill. //write an output statement that prints totalBill with a label to the // output file. // write statements to close the files. return 0; }
//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 ouput will go to an output file.
# include <ifstream> // needed to use files.
# 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; //number of item purchased
double itemPrice; // price of each item
double totalBill; // total price of all items
dataIn.open ("transaction.dat"); //These 2 statements open file.
dataOut.open("bill.out");
--- ------setprecision(2)<< fixed<< showpoint; // format output in the output file
// write an input statement that brings the quantity and price
// of the item in form of data file. // write an assignment statement that places the correct value in totalbill. //write an output statement that prints totalBill with a label to the // output file. // write statements to close the files. return 0; }
Explanation / Answer
please rate -thanks
hope this is good, if not get back to me
//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 ouput will go to an output file.
# include <fstream> // needed to use files.
# 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; //number of item purchased
double itemPrice; // price of each item
double totalBill; // total price of all items
dataIn.open ("transaction.dat"); //These 2 statements open file.
dataOut.open("bill.out");
dataOut<<setprecision(2)<< fixed<< showpoint; // format output in the output file
// write an input statement that brings the quantity and price
// of the item in form of data file.
dataIn>>quantity>>itemPrice;
// write an assignment statement that places the correct value in totalbill.
totalBill=quantity*itemPrice;
//write an output statement that prints totalBill with a label to the
// output file.
dataOut<<"total price = "<<totalBill;
// write statements to close the files.
dataOut.close();
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.