Write a program that processes a list of items purchased with a receipt
List in itemlist.txt just items different numbers
Prices in pricelist.txt have items and prices in them, different #
Make file output file that has receipt
Print message saying program ran- have not done
If item not in pricelist, report error, count errors display at end
Don't know how many items or prices
Close file and clear because of running many these files many times
This program wont write to the files like so the above is what i have to do
#include<iostream>`enter code here`
#include<fstream>
#include<cstdlib>
#include<iomanip>
using namespace std;
int main()
{
ifstream in_stream; // reads itemlist.txt
ofstream out_stream1; // writes in items.txt
ifstream in_stream2; // reads pricelist.txt
ofstream out_stream3;// writes in plist.txt
ifstream in_stream4;// read recipt.txt
ofstream out_stream5;// write display.txt
double price=' ',curr_total=0.0;
int wrong=0;
int itemnum=' ';
char next;
in_stream.open("ITEMLIST.txt", ios::in); // list of avaliable items
out_stream1.open("listWititems.txt", ios::out); // list of avaliable items
in_stream2.open("PRICELIST.txt", ios::in);
out_stream3.open("listWitdollars.txt", ios::out);
in_stream4.open("display.txt", ios::in);
out_stream5.open("showitems.txt", ios::out);
in_stream.setf(ios::fixed);
while(!in_stream.eof())
{
in_stream >> itemnum;
cin.clear();
cin >> next;
}
out_stream1.setf(ios::fixed);
while (!out_stream1.eof())
{
out_stream1 << itemnum;
cin.clear();
cin >> next;
}
in_stream2.setf(ios::fixed);
in_stream2.setf(ios::showpoint);
in_stream2.precision(2);
while (!in_stream2.eof()) // reads file to end of file
{
while((price== (price*1.00)) && (itemnum == (itemnum*1)))
{
in_stream2 >> itemnum >> price;
itemnum++;
price++;
curr_total= price++;
in_stream2 >> curr_total;
cin.clear(); // allows more reading
cin >> next;
return itemnum, price;
}
}
out_stream3.setf(ios::fixed);
out_stream3.setf(ios::showpoint);
out_stream3.precision(2);
while (!out_stream3.eof()) // reads file to end of file
{
while((price== (price*1.00)) && (itemnum == (itemnum*1)))
{
out_stream3 << itemnum << price;
itemnum++;
price++;
curr_total= price++;
out_stream3 << curr_total;
cin.clear(); // allows more reading
cin >> next;
return itemnum, price;
}
}
in_stream4.setf(ios::fixed);
in_stream4.setf(ios::showpoint);
in_stream4.precision(2);
while (!in_stream4.eof())
{
in_stream4 >> itemnum >> price >> curr_total;
cin.clear();
cin >> next;
}
out_stream5.setf(ios::fixed);
out_stream5.setf(ios::showpoint);
out_stream5.precision(2);
out_stream5 <<setw(5)<< " itemnum " <<setw(5)<<" price "<<setw(5)<<" curr_total " <<endl; // sends items and prices to receipt.txt
out_stream5 << setw(5) << itemnum << setw(5) <<price << setw(5)<< curr_total; // sends items and prices to receipt.txt
out_stream5 << " You have a total of " << wrong++ << " errors " << endl;
in_stream.close(); // closing files.
out_stream1.close();
in_stream2.close();
out_stream3.close();
in_stream4.close();
out_stream5.close();
system("pause");
}