By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,584 Members | 3,458 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,584 IT Pros & Developers. It's quick & easy.

how to display the item order if choose checkout

P: 1
cout << "Item Price Availability"<<endl;
cout << "1. Samsung Php 20 "<<samsungAvail<<endl;
cout << "2. iPhone Php 50 "<<iphoneAvail<<endl;
cout << "0. Checkout Total Amount["<<amount<<"]"<<endl;
cout << "choose your item: ";
cin >> choose;

while(choose != 0){
if(choose == 1){
cout << "samsung Php 20" <<endl;
cout << "Quantity ";
cin >> qty;
amount += qty * 20;
samsungAvail = samsungAvail - qty;
cout << "Amount " << amount <<endl;
}
if(choose == 2){
cout << "iPhone Php 50" <<endl;
cout << "Quantity ";
cin >> qty;
amount += qty * 50;
iphoneAvail = iphoneAvail - qty;
cout << "Amount " << amount <<endl;
}
}
Feb 11 '19 #1
Share this Question
Share on Google+
1 Reply


dev7060
100+
P: 120
How about this?
Expand|Select|Wrap|Line Numbers
  1. do{
  2. cout << "Item Price Availability"<<endl;
  3. cout << "1. Samsung Php 20 "<<samsungAvail<<endl;
  4. cout << "2. iPhone Php 50 "<<iphoneAvail<<endl;
  5. cout << "0. Checkout Total Amount["<<amount<<"]"<<endl;
  6. cout << "choose your item: ";
  7. cin >> choose;
  8.  
  9. if(choose == 1){
  10. cout << "samsung Php 20" <<endl;
  11. cout << "Quantity ";
  12. cin >> qty;
  13. amount += qty * 20;
  14. samsungAvail = samsungAvail - qty;
  15. cout << "Amount " << amount <<endl;
  16. }
  17. else if(choose == 2){
  18. cout << "iPhone Php 50" <<endl;
  19. cout << "Quantity ";
  20. cin >> qty;
  21. amount += qty * 50;
  22. iphoneAvail = iphoneAvail - qty;
  23. cout << "Amount " << amount <<endl;
  24. }
  25. }while(choose!=0);
  26.  
  27.  
Feb 17 '19 #2

Post your reply

Sign in to post your reply or Sign up for a free account.