I have just started studying C++ and am trying to write an interactive C++ program. The program should be a form of supermarket receipt. The format/sample is given below

CASH 20000

ITEM(S) PRICE

Soap 2000
beef 3000
cake 1500
book 2000
Bags 4000

CHANGE 7500

I have tried my best but i couldn't produce the right code. please any form of assistance highly appreciated

>I have tried my best but i couldn't produce the right code.
Post your best attempt and we'll help you correct it.

>I have tried my best but i couldn't produce the right code.
Post your best attempt and we'll help you correct it.

Hi thanks for willing to assist. Here is the code:

#include <iostream.h>
int Balance;
 char name [4];
int price, cash, total=0;
int main()
{

cout<<"Enter the cash ";
cin>>cash;
cout<<"cash\t\t\t"<<cash<<'\n';
cout<<"ITEM(S)\t\t\t"<<"PRICE\n";
cout<<"............................."<<'\n';
do
{
cout<<"Enter product Name";
cin>>name;

cout<<"Enter price of the item";
cin>>price;
cout<<name <<"\t\t\t"<<price<<'\n';
cout<<".............................."<<'\n';
total=total+price;
}
while (name != "i");
Balance=cash-total;
cout<<"TOTAL\t\t\t"<<total;
cout<<"BALANCE\t\t\t"<<Balance;

return 0;
}

> I supposed I could mention this, but chances are you'll ignore it.
> http://www.daniweb.com/forums/announcement8-3.html

Oh well, that's it then
> Last edited by Narue : 8 Hours Ago at 21:41. Reason: added code tags

Move along, nothing to see here.

Just another starving man, who on stumbling upon a banquet was unable to recognise that what was being offered was food.

This article has been dead for over six months. Start a new discussion instead.