I am trying to write a program that cerate’s a in invoice. And i am trying to use cin.eof() for the program to recognise when the input file has come to an end…
And this is the file I am trying to input from.Code:int main(int argc, char *argv[])
{
int quantity, numberOfItems; float price, itemTotal, total=0; string productID;
cout << "PHANTOM COMPAY INVOICE\n\n"
<< "PRODUCT ID QUANTITY PRICE PRICE\n\n";
while (cin.eof())
{
cin >> productID >> quantity >> price; // Read values from invoic.dat
itemTotal = quantity*price; // calculate total cost for items
cout << productID << setw(18-productID.size()) // display product id
<< quantity << setw(11) // display quantity
<< price << setw(8) // display price for one item
<< itemTotal << endl; // display price for all items
total = total + itemTotal; // calculate cost of all items
}
cout << endl
<< setw(34) << "TOTAL: " << total; // display total cost of all items
return EXIT_SUCCESS;
}
and I am using this bat file I created to run the programQuote:
Originally Posted by purchase.dat
for my output all i get isQuote:
Originally Posted by Invoice.bat
Quote:
Originally Posted by statment.txt