Ad Code

Responsive Advertisement

Write a program that same as a ADD TO CART(BUY,REMOVE,TOTAL BILL ) in c++.




#include<iostream>
#include<stdlib.h>
using namespace std;

int main()
{
 int i,j,k,n[5],a[10],l=0,z=0,sum=0;
 system("clear");
 x:
 cout<<"\n1.Buy";
 cout<<"\n2.remove";
 cout<<"\n3.total bill";
 cout<<"\n\n Enter your choice :";
 int ch;
 cin>>ch;

 if(ch==1)
 {
  cout<<"\n\n1.Mango price : 200\n2.Orange price : 150\n3. Banana price : 100\n4.stobery price : 250\n5.Pynaple price : 300";
  cout<<"\n\nEnter your ch :";
  int ch1;
  cin>>ch1;
  if(l<=4){
   if(ch1==1){
    a[l]=200;
    l++;
    z=l;
   } 
   if(ch1==2){
    a[l]=150;
    l++;
    z=l;
   }
   if(ch1==3){
    a[l]=100;
    l++;
    z=l;
   }
   if(ch1==4){
    a[l]=250;
    l++;
    z=l;
   }
   if(ch1==5){
    a[l]=300;
    l++;
   }
  }
 }

 sum=0;
 for(i=0; i<l; i++)
 {
  cout<<"\n"<<a[i];
  
 }

 if(ch==2)
 {
  cout<<"\n\nEnter a product possition   :";
  int po;
  cin>>po;
  l--;
  
  for(i=po-1; i<5; i++)
  {
  
   a[i]=a[i+1];   
  }
  sum=0;
  for(i=0; i<l; i++)
  {
   cout<<"\n"<<a[i];
  }

 
 }
 if(ch==3){
  sum=0;
  for(i=0; i<l; i++)
  {
   sum=sum+a[i];
  }
  cout<<"\n\n your Total bill is :"<<sum<<endl<<"\n";
 }

 cout<<"\n\n Do you want to again  : (Y/N)";
 char h;
 cin>>h;
 if(h=='y'){
  int x;
  goto x;
 }
}

Post a Comment

0 Comments