| | |
Can somebody please help me write this code
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2008
Posts: 2
Reputation:
Solved Threads: 0
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
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
So post what you can achieve yourself, then we'll help
http://www.daniweb.com/forums/announcement8-2.html
I supposed I could mention this, but chances are you'll ignore it.
http://www.daniweb.com/forums/announcement8-3.html
http://www.daniweb.com/forums/announcement8-2.html
I supposed I could mention this, but chances are you'll ignore it.
http://www.daniweb.com/forums/announcement8-3.html
•
•
Join Date: Oct 2008
Posts: 2
Reputation:
Solved Threads: 0
•
•
•
•
>I have tried my best but i couldn't produce the right code.
Post your best attempt and we'll help you correct it.
C++ Syntax (Toggle Plain Text)
#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; }
Last edited by Narue; Oct 21st, 2008 at 5:41 pm. Reason: added code tags
samjars,
two suggestions:
1. when comparing two strings you may want to use the strcmp function on string.h
Have a look at http://www.daniweb.com/forums/thread5663.html
2. you'd like to think about controlling the flow with another type of loop... otherwise you need to enter price=0 for item i.
two suggestions:
1. when comparing two strings you may want to use the strcmp function on string.h
Have a look at http://www.daniweb.com/forums/thread5663.html
2. you'd like to think about controlling the flow with another type of loop... otherwise you need to enter price=0 for item i.
> 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.
> 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.
![]() |
Similar Threads
- how do i write the code for taking out a hard copy of the web page (HTML and CSS)
- Write C++ Code (C++)
- Can we Programaticall Write code in VB6.0, forms/standard module/class code window (Visual Basic 4 / 5 / 6)
- Could somebody write code for my project plz... (Visual Basic 4 / 5 / 6)
- Could Somebody Write Code Plz... (Visual Basic 4 / 5 / 6)
- I need to write a C++ Code from the following info. HOW DO I... (C++)
- How do you write a code which compiles in c but not in c++? (C++)
Other Threads in the C++ Forum
- Previous Thread: Printing 2D array
- Next Thread: Prime Number
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






