Calculate Shopping bill
A c++ code to calculate the shopping bill .
Calculate Shopping bill
// c++ code to calculate
#include<bits/stdc++.h>
using namespace std;
int main()
{
cout<<"Welcome to the online shopping center!!!"<<endl;
cout<<"Check out the following items : "<<endl;
cout<<endl;
cout<<"1) Sugar: 80/- kg, 2) Tea: 120/- kg, 3)Milk: 50/- lit"<<endl;
cout<<"4) Blue pen: 10/- 1p, 5)Notebook: 45/- 1p, 6) Bread: 45/- pp"<<endl;
cout<<"7) Rice: 40/- kg, 8) Tur daal: 80/- kg, 9) Wheat: 30/- kg"<<endl;
cout<<"10) Moong dal: 120/-, 11) Chocolates: 10/- 1p, 12) Butter: 70/- pp"<<endl;
cout<<endl;
cout<<"Please enter the number of items in your list: "<<endl;
int n;
cin>>n;
string arr[n];
cout<<"Please enter the items in your list: "<<endl;
cout<<endl;
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
cout<<"The items entered are: "<<endl;
cout<<endl;
for(int i=0;i<n;i++)
{
cout<<arr[i]<<endl;
}
int sum=0;
for(int i=0;i<n;i++){
if(arr[i]=="Sugar")
{
sum+=80;
}
else if(arr[i]=="Tea"){
sum+=120;
}
else if(arr[i]=="Milk"){
sum+=50;
}
else if(arr[i]=="Blue Pen"){
sum+=10;
}
else if(arr[i]=="Notebook"){
sum+=45;
}
else if(arr[i]=="Bread"){
sum+=45;
}
else if(arr[i]=="Rice"){
sum+=40;
}
else if(arr[i]=="Tur Daal"){
sum+=80;
}
else if(arr[i]=="Wheat"){
sum+=30;
}
else if(arr[i]=="Moong dal"){
sum+=120;
}
else if(arr[i]=="Chocolates"){
sum+=10;
}
else if(arr[i]=="Butter"){
sum+=70;
}
}
cout<<"Your total bill: "<<sum<<endl;
}


