There are a lot of errors in my code that will not let the program run.
It asks the user to enter the code of the item purchased by the customer. If the user enters a code that is not in the choices, it asks again until he/she enters a valid code. Then, its description and price are displayed on the screen. Also, it asks for the quantity of the particular item code entered. Again, if the user enters a zero or negative value, it asks again for the quantity until he or she enters a valid value. Afterwards, it displays the subtotal amount. It will keep on asking for an item code, and will process the same until such time that the user enters ‘0’. When the user enters ‘0’, the total amount due is displayed. Then, it asks the user to tender the amount of cash of the customer. If the amount tendered is less than the amount due, it asks again for the amount until he or she enters a valid amount. Then, it prints the change due to the customer and its breakdown. Finally, it asks the user if he or she wants to process more transactions.
Here is what I did so far.
cout<<"Do you want a new transaction? [y/n]"<<endl;
cin>>response;
while (response == 'y' || response == 'Y')
{
((((ITEM CODES DISPLAYED HERE)))
cout<<" Enter item code [1-10]"<<endl;
cin>>code;
total += 0;
switch (code)
case 1:
cout<<"Ballpen Php"<<bPen<<endl;
cout<<"How many ballpen do you want to buy?"<<endl;
cin>>quant;
do
{
sBpen = quant * bPen;
cout<<" Ballpen x "<<quant<<" = "<<sBpen;
while (quant < 0)
cout<<"Invaid quantity. Please enter a valid one."<<endl;
cin>>quant;
}
case 0:
cout<<"Total: "<<price;
break;
default:
cout<<"Invalid code. Please enter a valid one."<<endl;
cin>>code;
total += sTotal;
while (code != 0)
{ cout<<"Do you want more transaction?"<<endl;
cin>>response;
}
}
getch ();
return 0;
}