A small market maintains an inventory of exactly 20 items Yo
A small market maintains an inventory of exactly 20 items. You will read these items from a file. Each item named will have an associated cost and a character code to indicate whether or not it is taxable. You will place your online order. A file will contain your \"printed\" receipt with the total amount of your order.
gallon-milk 3.29 N
ice-5lbs 0.99 N
barsoap-6pk 4.39 T
shampoo 4.94 T
lotion 4.99 T
cereal 2.30 N
bagels-6pk 1.99 N
muffins-2pk 2.10 N
muffins-3pk 3.49 N
eggs-dozen 0.89 N
bread 0.99 N
butter-1lb 2.35 N
cookingOil 3.29 N
sugar-1lb 1.39 N
detergent 4.99 T
bleach 0.99 T
orangeJuice 1.99 N
coffee-6oz 5.19 N
sugar-3lb 2.09 N
teabags50 2.99 N
motoroil 1.39 T
iceshovel 12.99 T
potato-5lb 2.49 N
cola-12pk 3.99 N
phonecard25 5.00 T
phonecard60 10.00 T
Solution
#include <iostream>
#include <fstream>
using namespace std;
int main(){
char arr[515];
int charge_acc_no;
ifstream fin(\"orders.txt\");
int position=0;
int choice=0;
// float costArray[25]={\'3.29,0.99,4.39,4.94,4.99,2.30,1.99,2.10,3.49,0.89,0.99,2.35,3.29,1.39,4.99,0.99,1.99,5.19,2.09,2.99,1.39,12.99,2.49,3.99,5.0,10.0};
float totalCost=0.0;
if(fin.is_open())
{
cout << \"File Opened successfully!!!. Reading data from file into array\" << endl;
for(int i=0;i<sizeof(arr);i++)
{
fin.get(arr[i]); //reading one character from file to array
}
cout << \"\ Displaying Item List...\" << endl << endl;
for(int i = 0;i<sizeof(arr); i++)
{
cout << arr[i];
}
/* //calculate the bill as per your requirements and tax value
do{
cout<<\"\ Please enter the item serial number to buy the item(press 0 to exit):\";
cin>>choice;
for(int i=choice;i==choice;i++){
totalCost=totalCost+costArray[choice];
}
}while(choice>0 && choice<21);
cout<<\"\ Total Cost to be paid is:\"<<totalCost<<endl;
*/ }
else //file could not be opened
{
cout << \"File could not be opened.\" << endl;
}
}

