Can somebody please help me write this code

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2008
Posts: 2
Reputation: samjars is an unknown quantity at this point 
Solved Threads: 0
samjars samjars is offline Offline
Newbie Poster

Can somebody please help me write this code

 
0
  #1
Oct 21st, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,622
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 713
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Can somebody please help me write this code

 
0
  #2
Oct 21st, 2008
>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'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Can somebody please help me write this code

 
0
  #3
Oct 21st, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2
Reputation: samjars is an unknown quantity at this point 
Solved Threads: 0
samjars samjars is offline Offline
Newbie Poster

Re: Can somebody please help me write this code

 
0
  #4
Oct 21st, 2008
Originally Posted by Narue View Post
>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:
  1. #include <iostream.h>
  2. int Balance;
  3. char name [4];
  4. int price, cash, total=0;
  5. int main()
  6. {
  7.  
  8. cout<<"Enter the cash ";
  9. cin>>cash;
  10. cout<<"cash\t\t\t"<<cash<<'\n';
  11. cout<<"ITEM(S)\t\t\t"<<"PRICE\n";
  12. cout<<"............................."<<'\n';
  13. do
  14. {
  15. cout<<"Enter product Name";
  16. cin>>name;
  17.  
  18. cout<<"Enter price of the item";
  19. cin>>price;
  20. cout<<name <<"\t\t\t"<<price<<'\n';
  21. cout<<".............................."<<'\n';
  22. total=total+price;
  23. }
  24. while (name != "i");
  25. Balance=cash-total;
  26. cout<<"TOTAL\t\t\t"<<total;
  27. cout<<"BALANCE\t\t\t"<<Balance;
  28.  
  29. return 0;
  30. }
Last edited by Narue; Oct 21st, 2008 at 5:41 pm. Reason: added code tags
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 87
Reputation: freelancelote is an unknown quantity at this point 
Solved Threads: 2
freelancelote's Avatar
freelancelote freelancelote is offline Offline
Junior Poster in Training

Re: Can somebody please help me write this code

 
0
  #5
Oct 21st, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Can somebody please help me write this code

 
0
  #6
Oct 22nd, 2008
> 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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC