I want to make a menu driven program in which I have 4 options
1) input() -Inputs the data WITH A UNIQUE KEY (AND CHECKS FOR REPETION) and writes it to a file
2)output() - Outputs the data using a UNIQUE KEY (WHICH WHEN NOT FOUND GIVES AN ERROR)
3)delete() - Deletes the record corresponding to the entered unique id
4) shows all the unique keys entered (just for reference if the user forgets
Rest everything is Working Perfectly Fine! I am actually not clear with the use of read() and write().
The usage of Unique key that is like a primary key is probably not correct and I'm unable to correct it.
Please help !
#include<iostream>
#include<iomanip>
#include<conio.h>
#include<cstdlib>
#include<fstream>
#include<string.h>
#include<stdio.h>
using namespace std;
int a[1],b[1],c[1];
char* logname[] ={"UNKOWN","BlueDart","FedEx","Delhivery","DTDC/FirstFlight","Ecom Express","India Post","ATS","Ekart","Aramex"} ;
char* wbname[] = {"UNKNOWN","Flipkart","Amazon","SnapDeal","PayTM","eBay","ShopClues"};
/*Made By SAMEER KUMAR
Class XII-C
www.sameerkumar.website
All Rights Reserved!
*/
class Expenditures
{ public:
int codfee,logfee;
float x,a,b,fvfee,t,dedc,inhand;
char categname[40];
int f;
int cod,city,log,category,wb,sp;
float tax,texp,total,exp;
float w,h;
float pkfee;
float trfee,mkpfee;
int choice1, choice2;
float l;
/*
Expenditures()
{
fvfee=0;
x=0;
logfee=0;
a=0;//trf
b=0;//mkpf
t=0;//total
codfee=0;//cod
cout<<endl<<"Calaculating.........."<<endl;
} */
void finalvfee()
{
switch(wb)
{
case 1: switch(category)//Flipkart
{
case 1: fvfee=(10*sp)/100; break; //fvfee=(10*sp)/100;
case 2: fvfee=(10*sp)/100; break;
case 3: fvfee=(4*sp)/100; break;
case 4: fvfee=(8*sp)/100; break;
case 5: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 6: fvfee=(10*sp)/100; break;
case 7: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 8: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 9: fvfee=(10*sp)/100; break;
case 10: fvfee=(10*sp)/100; break;
case 11: fvfee=(10*sp)/100; break;
case 12: fvfee=(10*sp)/100; break;
case 13: fvfee=(10*sp)/100; break;
case 14: fvfee=(10*sp)/100; break;
case 15: fvfee=(10*sp)/100; break;
case 16: fvfee=(10*sp)/100; break;
case 17: fvfee=(4*sp)/100; break;
case 18: fvfee=(5*sp)/100; break;
case 19: fvfee=(4*sp)/100; break;
case 20: fvfee=(4*sp)/100; break;
case 21: fvfee=(4*sp)/100; break;
case 22: fvfee=(4*sp)/100; break;
case 23: fvfee=(10*sp)/100; break;
case 24: fvfee=(8*sp)/100; break;
case 25: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 26: fvfee=(10*sp)/100; break;
case 27: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 28: fvfee=(10*sp)/100; break;
case 29: fvfee=(4*sp)/100; break;
case 30: fvfee=(10*sp)/100; break;
case 31: fvfee=(12*sp)/100; break;
case 32: fvfee=(10*sp)/100; break;
case 33: fvfee=(10*sp)/100; break;
case 34: fvfee=(4*sp)/100; break;
case 35: fvfee=(4*sp)/100; break;
case 36: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 37: fvfee=(10*sp)/100; break;
default: cerr<<"Wrong Choice!!"; exit(0);break;
}break;
case 2: switch(category)//SnapDeal
{
case 1: fvfee=(9*sp)/100; break; //fvfee=(10*sp)/100;
case 2: fvfee=(9*sp)/100; break;
case 3: fvfee=(5*sp)/100; break;
case 4: fvfee=(7*sp)/100; break;
case 5: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 6: fvfee=(7*sp)/100; break;
case 7: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 8: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 9: fvfee=(8*sp)/100; break;
case 10: fvfee=(10*sp)/100; break;
case 11: fvfee=(10*sp)/100; break;
case 12: fvfee=(10*sp)/100; break;
case 13: fvfee=(10*sp)/100; break;
case 14: fvfee=(10*sp)/100; break;
case 15: fvfee=(10*sp)/100; break;
case 16: fvfee=(10*sp)/100; break;
case 17: fvfee=(3*sp)/100; break;
case 18: fvfee=(4*sp)/100; break;
case 19: fvfee=(5*sp)/100; break;
case 20: fvfee=(4*sp)/100; break;
case 21: fvfee=(4*sp)/100; break;
case 22: fvfee=(4*sp)/100; break;
case 23: fvfee=(10*sp)/100; break;
case 24: fvfee=(7*sp)/100; break;
case 25: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 26: fvfee=(10*sp)/100; break;
case 27: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 28: fvfee=(10*sp)/100; break;
case 29: fvfee=(4*sp)/100; break;
case 30: fvfee=(10*sp)/100; break;
case 31: fvfee=(12*sp)/100; break;
case 32: fvfee=(10*sp)/100; break;
case 33: fvfee=(10*sp)/100; break;
case 34: fvfee=(4*sp)/100; break;
case 35: fvfee=(4*sp)/100; break;
case 36: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 37: fvfee=(9.5*sp)/100; break;
default: cerr<<"Wrong Choice!!"; exit(0);break;
} break;
case 3://Amazon
if(sp<250)
{fvfee=0;}
else if(sp>250&&sp<500)
{fvfee=5;}
else if(sp>500)
{fvfee=10;}
break;
case 4: switch(category)//PayTM
{
case 1: fvfee=(7*sp)/100; break;
case 2: fvfee=(7*sp)/100; break;
case 3: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 4: fvfee=(7*sp)/100; break;
case 5: fvfee=(2.5*sp)/100; break;
case 6: fvfee=(14*sp)/100; break;
case 7: fvfee=(2*sp)/100; break;
case 8: fvfee=(5*sp)/100; break;
case 9: fvfee=(8*sp)/100; break;
case 10: fvfee=(7*sp)/100; break;
case 11: fvfee=(7*sp)/100; break;
case 12: fvfee=(9*sp)/100; break;
case 13: fvfee=(15.2*sp)/100; break;
case 14: fvfee=(4*sp)/100; break;
case 15: fvfee=(2*sp)/100; break;
case 16: fvfee=(15*sp)/100; break;
case 17: fvfee=(2*sp)/100; break;
case 18: fvfee=(6*sp)/100; break;
case 19: fvfee=(5*sp)/100; break;
case 20: fvfee=(2*sp)/100; break;
case 21: fvfee=(10*sp)/100; break;
case 22: fvfee=(2.5*sp)/100; break;
case 23: fvfee=(9*sp)/100; break;
case 24: fvfee=(5*sp)/100; break;
case 25: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 26: fvfee=(12*sp)/100; break;
case 27: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 28: fvfee=(8*sp)/100; break;
case 29: fvfee=(2*sp)/100; break;
case 30: fvfee=(15*sp)/100; break;
case 31: fvfee=(15*sp)/100; break;
case 32: fvfee=(12*sp)/100; break;
case 33: fvfee=(7*sp)/100; break;
case 34: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 35: fvfee=(14*sp)/100; break;
case 36: fvfee=(9*sp)/100; break;
case 37: fvfee=(8*sp)/100; break;
default: cerr<<"Wrong Choice!!"; exit(0);break;
}
break;
case 5: switch(category)//eBay
{
case 1: fvfee=(5*sp)/100; break;
case 2: fvfee=(6*sp)/100; break;
case 3: fvfee=(4*sp)/100; break;
case 4: fvfee=(7*sp)/100; break;
case 5: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 6: fvfee=(7*sp)/100; break;
case 7: fvfee=(7*sp)/100; break;
case 8: fvfee=(7*sp)/100; break;
case 9: fvfee=(7*sp)/100; break;
case 10: fvfee=(5*sp)/100; break;
case 11: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 12: fvfee=(5*sp)/100; break;
case 13: fvfee=(7*sp)/100; break;
case 14: fvfee=(5*sp)/100; break;
case 15: fvfee=(7*sp)/100; break;
case 16: fvfee=(5*sp)/100; break;
case 17: fvfee=(2*sp)/100; break;
case 18: fvfee=(1*sp)/100; break;
case 19: fvfee=(1*sp)/100; break;
case 20: fvfee=(5*sp)/100; break;
case 21: fvfee=(1*sp)/100; break;
case 22: fvfee=(1*sp)/100; break;
case 23: fvfee=(6*sp)/100; break;
case 24: fvfee=(7*sp)/100; break;
case 25: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 26: fvfee=(7*sp)/100; break;
case 27: fvfee=(5*sp)/100; break;
case 28: fvfee=(6*sp)/100; break;
case 29: fvfee=(1*sp)/100; break;
case 30: fvfee=(6*sp)/100; break;
case 31: fvfee=(7*sp)/100; break;
case 32: fvfee=(6*sp)/100; break;
case 33: fvfee=(7*sp)/100; break;
case 34: fvfee=(5*sp)/100; break;
case 35: fvfee=(2*sp)/100; break;
case 36: fvfee=(2.5*sp)/100; break;
case 37: fvfee=(7*sp)/100; break;
default : cerr<<"Wrong Choice!!"; exit(0);break;
}
break;
case 6: switch(category)//ShopClues
{
case 1: fvfee=(12*sp)/100; break;
case 2: fvfee=(15*sp)/100; break;
case 3: fvfee=(7*sp)/100; break;
case 4: fvfee=(12*sp)/100; break;
case 5: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 6: fvfee=(15*sp)/100; break;
case 7: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 8: cout<<"This Category Cannot be sold on this Website"; exit(0); break;
case 9: fvfee=(12*sp)/100; break;
case 10: fvfee=(17*sp)/100; break;
case 11: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 12: fvfee=(12*sp)/100; break;
case 13: fvfee=(14*sp)/100; break;
case 14: fvfee=(6*sp)/100; break;
case 15: fvfee=(17*sp)/100; break;
case 16: fvfee=(15*sp)/100; break;
case 17: fvfee=(4*sp)/100; break;
case 18: fvfee=(6*sp)/100; break;
case 19: fvfee=(4*sp)/100; break;
case 20: fvfee=(12*sp)/100; break;
case 21: fvfee=(6*sp)/100; break;
case 22: fvfee=(6*sp)/100; break;
case 23: fvfee=(15*sp)/100; break;
case 24: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 25: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 26: fvfee=(15*sp)/100; break;
case 27: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 28: fvfee=(15*sp)/100; break;
case 29: fvfee=(6*sp)/100; break;
case 30: cout<<"This Category Cannot be sold on this Website"; exit(0);break;
case 31: fvfee=(12*sp)/100; break;
case 32: fvfee=(8*sp)/100; break;
case 33: fvfee=(15*sp)/100; break;
case 34: fvfee=(20*sp)/100; break;
case 35: fvfee=(8*sp)/100; break;
case 36: fvfee=(10*sp)/100; break;
case 37: fvfee=(10*sp)/100; break;
default : cerr<<"Wrong Choice!!"; exit(0);break;
}
break;
default : cerr<<"Wrong Choice!!"; exit(0);break;
}
}
float logistics(int city,float w,int cod,int log)
{
//Expenditures ef;
switch(log)
{
case 1: if(city==1)
{if (w<=500){logfee=30;}
else if(w>=501 && w<=1000){logfee=30+(1*(35));}
else if(w>=1001 && w<=1500){logfee=30+(2*(35));}
else if(w>=1501 && w<=2000){logfee=30+(3*(35));}
else if(w>=2001 && w<=2500){logfee=30+(4*(35));}
else if(w>=2501 && w<=3000){logfee=30+(5*(35));}
else if(w>=3001 && w<=3500){logfee=30+(6*(35));}
else if(w>=3501 && w<=4000){logfee=30+(7*(35));}
else if(w>=4001 && w<=4500){logfee=30+(8*(35));}
else if(w>=4501 && w<=5000){logfee=30+(9*(35));}
else if(w<=5001){ cout<<"Contact Customer Care!!";
cout<<"Press 1 to Continue or Press 2 to Try Again Later";
cin>>choice1;
if(choice1==1){logfee=0; break;}
else if(!choice1==1){cerr<<"Wrong Choice!!"; exit(0);}
}
else {cerr<<"Wrong Choice!!"; exit(0);}
}
else if(city==2)
{if (w<=500){logfee=50;}
else if(w>=501 && w<=1000){logfee=50+(1*(55));}
else if(w>=1001 && w<=1500){logfee=50+(2*(55));}
else if(w>=1501 && w<=2000){logfee=50+(3*(55));}
else if(w>=2001 && w<=2500){logfee=50+(4*(55));}
else if(w>=2501 && w<=3000){logfee=50+(5*(55));}
else if(w>=3001 && w<=3500){logfee=50+(6*(55));}
else if(w>=3501 && w<=4000){logfee=50+(7*(55));}
else if(w>=4001 && w<=4500){logfee=50+(8*(55));}
else if(w>=4501 && w<=5000){logfee=50+(9*(55));}
else if(w<=5001){cout<<"Contact Customer Care!!";
cout<<"Press 1 to Continue or Press 2 to Try Again Later";
cin>>choice1;
if(choice1==1){logfee=0;}
else if(!choice1==1){cerr<<"Wrong Choice!!"; exit(0);}
}
else {cerr<<"Wrong Choice!!"; exit(0);}
}
else {cerr<<"Wrong Choice!!"; exit(0);}
/*switch(cod)
{case 1: codfee=0; break;
case 2: codfee=0; break;
default: cerr<<"Wrong Choice!!"; exit(0);}
*/
if(cod==1){codfee=0;} else {codfee=0;}
break;
case 2: if(city==1)
{if (w<=500){logfee=36;}
else if(w>=501 && w<=1000){logfee=36+(1*(40));}
else if(w>=1001 && w<=1500){logfee=36+(2*(40));}
else if(w>=1501 && w<=2000){logfee=36+(3*(40));}
else if(w>=2001 && w<=2500){logfee=36+(4*(40));}
else if(w>=2501 && w<=3000){logfee=36+(5*(40));}
else if(w>=3001 && w<=3500){logfee=36+(6*(40));}
else if(w>=3501 && w<=4000){logfee=36+(7*(40));}
else if(w>=4001 && w<=4500){logfee=36+(8*(40));}
else if(w>=4501 && w<=5000){logfee=36+(9*(40));}
else if(w<=5001){ cout<<"Contact Customer Care!!";
cout<<"Press 1 to Continue or Press 2 to Try Again Later";
cin>>choice1;
if(choice1==1){logfee=0;}
else if(!choice1==1){cerr<<"Wrong Choice!!"; exit(0);}
}
else {cerr<<"Wrong Choice!!"; exit(0);}
}
else if(city==2)
{if (w<=500){logfee=56;}
else if(w>=501 && w<=1000){logfee=56+(1*(40));}
else if(w>=1001 && w<=1500){logfee=56+(2*(40));}
else if(w>=1501 && w<=2000){logfee=56+(3*(40));}
else if(w>=2001 && w<=2500){logfee=56+(4*(40));}
else if(w>=2501 && w<=3000){logfee=56+(5*(40));}
else if(w>=3001 && w<=3500){logfee=56+(6*(40));}
else if(w>=3501 && w<=4000){logfee=56+(7*(40));}
else if(w>=4001 && w<=4500){logfee=56+(8*(40));}
else if(w>=4501 && w<=5000){logfee=56+(9*(40));}
else if(w<=5001){cout<<"Contact Customer Care!!";
cout<<"Press 1 to Continue or Press 2 to Try Again Later";
cin>>choice1;
if(choice1==1){logfee=0;}
else if(!choice1==1){cerr<<"Wrong Choice!!"; exit(0);}
}
else {cerr<<"Wrong Choice!!"; exit(0);}
}
else {cerr<<"Wrong Choice!!"; exit(0);}
switch(cod){
case 1: cout<<"Not Available!!";
cout<<"Press 1 to Continue as NON COD or Press 2 to Try Again Later";
cin>>choice2;
if(choice2==1){break;}
else if(!choice2==1){exit(0);}else {cerr<<"Wrong Choice!!"; exit(0);} break;
case 2: codfee=0; break;
default: cerr<<"Wrong Choice!!"; exit(0);}
break;
case 3: if(city==1)
{if (w<=500){logfee=45;}
else if(w>=501 && w<=1000){logfee=45+(1*(47));}
else if(w>=1001 && w<=1500){logfee=45+(2*(47));}
else if(w>=1501 && w<=2000){logfee=45+(3*(47));}
else if(w>=2001 && w<=2500){logfee=45+(4*(47));}
else if(w>=2501 && w<=3000){logfee=45+(5*(47));}
else if(w>=3001 && w<=3500){logfee=45+(6*(47));}
else if(w>=3501 && w<=4000){logfee=45+(7*(47));}
else if(w>=4001 && w<=4500){logfee=45+(8*(47));}
else if(w>=4501 && w<=5000){logfee=45+(9*(47));}
else if(w<=5001){cout<<"Contact Customer Care!!";
cout<<"Press 1 to Continue or Press 2 to Try Again Later";
cin>>choice1;
if(choice1==1){logfee=0;}
else if(!choice1==1){cerr<<"Wrong Choice!!"; exit(0);}
}
else {cerr<<"Wrong Choice!!"; exit(0);}
}
else if(city==2)
{if (w<=500){logfee=65;}
else if(w>=501 && w<=1000){logfee=65+(1*(56));}
else if(w>=1001 && w<=1500){logfee=65+(2*(56));}
else if(w>=1501 && w<=2000){logfee=65+(3*(56));}
else if(w>=2001 && w<=2500){logfee=65+(4*(56));}
else if(w>=2501 && w<=3000){logfee=65+(5*(56));}
else if(w>=3001 && w<=3500){logfee=65+(6*(56));}
else if(w>=3501 && w<=4000){logfee=65+(7*(56));}
else if(w>=4001 && w<=4500){logfee=65+(8*(56));}
else if(w>=4501 && w<=5000){logfee=65+(9*(56));}
else if(w<=5001){cout<<"Contact Customer Care!!";
cout<<"Press 1 to Continue or Press 2 to Try Again Later";
cin>>choice1;
if(choice1==1){logfee=0;}
else if(!choice1==1){cerr<<"Wrong Choice!!"; exit(0);}
}
else {cerr<<"Wrong Choice!!"; exit(0);}
}
else cerr<<"Wrong Choice!!"; exit(0);
if(cod==1){codfee=30;} else {codfee=0;}
break;
case 4:
if(city==1)
{if (w<=500){logfee=25;}
else if(w>=501 && w<=1000){logfee=25+(1*(28));}
else if(w>=1001 && w<=1500){logfee=25+(2*(28));}
else if(w>=1501 && w<=2000){logfee=25+(3*(28));}
else if(w>=2001 && w<=2500){logfee=25+(4*(28));}
else if(w>=2501 && w<=3000){logfee=25+(5*(28));}
else if(w>=3001 && w<=3500){logfee=25+(6*(28));}
else if(w>=3501 && w<=4000){logfee=25+(7*(28));}
else if(w>=4001 && w<=4500){logfee=25+(8*(28));}
else if(w>=4501 && w<=5000){logfee=25+(9*(28));}
else if(w<=5001){cout<<"Contact Customer Care!!";
cout<<"Press 1 to Continue or Press 2 to Try Again Later";
cin>>choice1;
if(choice1==1){logfee=0;}
else if(!choice1==1){cerr<<"Wrong Choice!!"; exit(0);}
}
else {cerr<<"Wrong Choice!!"; exit(0);}
}
else if(city==2)
{if (w<=500){logfee=45;}
else if(w>=501 && w<=1000){logfee=45+(1*(48));}
else if(w>=1001 && w<=1500){logfee=45+(2*(48));}
else if(w>=1501 && w<=2000){logfee=45+(3*(48));}
else if(w>=2001 && w<=2500){logfee=45+(4*(48));}
else if(w>=2501 && w<=3000){logfee=45+(5*(48));}
else if(w>=3001 && w<=3500){logfee=45+(6*(48));}
else if(w>=3501 && w<=4000){logfee=45+(7*(48));}
else if(w>=4001 && w<=4500){logfee=45+(8*(48));}
else if(w>=4501 && w<=5000){logfee=45+(9*(48));}
else if(w<=5001){cout<<"Contact Customer Care!!";
cout<<"Press 1 to Continue or Press 2 to Try Again Later";
cin>>choice1;
if(choice1==1){logfee=0;}
else if(!choice1==1){cout<<"Wrong Choice"; exit(0);}else {cerr<<"Wrong Choice!!"; exit(0);}
}
else {cerr<<"Wrong Choice!!"; exit(0);}
}
else cerr<<"Wrong Choice!!"; exit(0);
if(cod==1){codfee=30;} else {codfee=0;}
break;
case 5: if(city==1)
{if (w<=500){logfee=55;}
else if(w>=501 && w<=1000){logfee=55+(1*(40));}
else if(w>=1001 && w<=1500){logfee=55+(2*(40));}
else if(w>=1501 && w<=2000){logfee=55+(3*(40));}
else if(w>=2001 && w<=2500){logfee=55+(4*(40));}
else if(w>=2501 && w<=3000){logfee=55+(5*(40));}
else if(w>=3001 && w<=3500){logfee=55+(6*(40));}
else if(w>=3501 && w<=4000){logfee=55+(7*(40));}
else if(w>=4001 && w<=4500){logfee=55+(8*(40));}
else if(w>=4501 && w<=5000){logfee=55+(9*(40));}
else if(w<=5001){cout<<"Contact Customer Care!!";
cout<<"Press 1 to Continue or Press 2 to Try Again Later";
cin>>choice1;
if(choice1==1){logfee=0;}
else if(!choice1==1){cerr<<"Wrong Choice!!"; exit(0);}
}
else {cerr<<"Wrong Choice!!"; exit(0);}
}
else if(city==2)
{if (w<=500){logfee=75;}
else if(w>=501 && w<=1000){logfee=75+(1*(60));}
else if(w>=1001 && w<=1500){logfee=75+(2*(60));}
else if(w>=1501 && w<=2000){logfee=75+(3*(60));}
else if(w>=2001 && w<=2500){logfee=75+(4*(60));}
else if(w>=2501 && w<=3000){logfee=75+(5*(60));}
else if(w>=3001 && w<=3500){logfee=75+(6*(60));}
else if(w>=3501 && w<=4000){logfee=75+(7*(60));}
else if(w>=4001 && w<=4500){logfee=75+(8*(60));}
else if(w>=4501 && w<=5000){logfee=75+(9*(60));}
else if(w<=5001){cout<<"Contact Customer Care!!";
cout<<"Press 1 to Continue or Press 2 to Try Again Later";
cin>>choice1;
if(choice1==1){logfee=0;}
else if(!choice1==1){cerr<<"Wrong Choice!!"; exit(0);}
}
else {cerr<<"Wrong Choice!!"; exit(0);}
}
else {cerr<<"Wrong Choice!!"; exit(0);}
switch(cod){
case 1: cout<<"Not Available!!";
cout<<"Press 1 to Continue as NON COD or Press 2 to Try Again Later";
cin>>choice2;
if(choice2==1){codfee=0;}
else if(!choice2==1){cerr<<"Wrong Choice!!"; exit(0);} break;
case 2: codfee=0; break;
default: cerr<<"Wrong Choice!!"; exit(0);}
break;
case 6: if(city==1)
{if (w<=500){logfee=30;}
else if(w>=501 && w<=1000){logfee=30+(1*(35));}
else if(w>=1001 && w<=1500){logfee=30+(2*(35));}
else if(w>=1501 && w<=2000){logfee=30+(3*(35));}
else if(w>=2001 && w<=2500){logfee=30+(4*(35));}
else if(w>=2501 && w<=3000){logfee=30+(5*(35));}
else if(w>=3001 && w<=3500){logfee=30+(6*(35));}
else if(w>=3501 && w<=4000){logfee=30+(7*(35));}
else if(w>=4001 && w<=4500){logfee=30+(8*(35));}
else if(w>=4501 && w<=5000){logfee=30+(9*(35));}
else if(w<=5001){cout<<"Contact Customer Care!!";
cout<<"Press 1 to Continue or Press 2 to Try Again Later";
cin>>choice1;
if(choice1==1){logfee=0;}
else if(!choice1==1){cerr<<"Wrong Choice!!"; exit(0);}
}
else {cerr<<"Wrong Choice!!"; exit(0);}
}
else if(city==2)
{if (w<=500){logfee=50;}
else if(w>=501 && w<=1000){logfee=50+(1*(55));}
else if(w>=1001 && w<=1500){logfee=50+(2*(55));}
else if(w>=1501 && w<=2000){logfee=50+(3*(55));}
else if(w>=2001 && w<=2500){logfee=50+(4*(55));}
else if(w>=2501 && w<=3000){logfee=50+(5*(55));}
else if(w>=3001 && w<=3500){logfee=50+(6*(55));}
else if(w>=3501 && w<=4000){logfee=50+(7*(55));}
else if(w>=4001 && w<=4500){logfee=50+(8*(55));}
else if(w>=4501 && w<=5000){logfee=50+(9*(55));}
else if(w<=5001){cout<<"Contact Customer Care!!";
cout<<"Press 1 to Continue or Press 2 to Try Again Later";
cin>>choice1;
if(choice1==1){logfee=0;}
else if(!choice1==1){cerr<<"Wrong Choice!!"; exit(0);}
}
else {cerr<<"Wrong Choice!!"; exit(0);}
}
else {cerr<<"Wrong Choice!!"; exit(0);}
if(cod==1){codfee=0;} else {codfee=0;}
break;
case 7: if(city==1)
{if (w<=500){logfee=40;}
else if(w>=501 && w<=1000){logfee=40+(1*(30));}
else if(w>=1001 && w<=1500){logfee=40+(2*(30));}
else if(w>=1501 && w<=2000){logfee=40+(3*(30));}
else if(w>=2001 && w<=2500){logfee=40+(4*(30));}
else if(w>=2501 && w<=3000){logfee=40+(5*(30));}
else if(w>=3001 && w<=3500){logfee=40+(6*(30));}
else if(w>=3501 && w<=4000){logfee=40+(7*(30));}
else if(w>=4001 && w<=4500){logfee=40+(8*(30));}
else if(w>=4501 && w<=5000){logfee=40+(9*(30));}
else if(w<=5001){cout<<"Contact Customer Care!!";
cout<<"Press 1 to Continue or Press 2 to Try Again Later";
cin>>choice1;
if(choice1==1){logfee=0;}
else if(!choice1==1){cerr<<"Wrong Choice!!"; exit(0);}
}
else {cerr<<"Wrong Choice!!"; exit(0);}
}
else if(city==2)
{if (w<=500){logfee=60;}
else if(w>=501 && w<=1000){logfee=60+(1*(50));}
else if(w>=1001 && w<=1500){logfee=60+(2*(50));}
else if(w>=1501 && w<=2000){logfee=60+(3*(50));}
else if(w>=2001 && w<=2500){logfee=60+(4*(50));}
else if(w>=2501 && w<=3000){logfee=60+(5*(50));}
else if(w>=3001 && w<=3500){logfee=60+(6*(50));}
else if(w>=3501 && w<=4000){logfee=60+(7*(50));}
else if(w>=4001 && w<=4500){logfee=60+(8*(50));}
else if(w>=4501 && w<=5000){logfee=60+(9*(50));}
else if(w<=5001){cout<<"Contact Customer Care!!";
cout<<"Press 1 to Continue or Press 2 to Try Again Later";
cin>>choice1;
if(choice1==1){logfee=0;}
else if(!choice1==1){cerr<<"Wrong Choice!!"; exit(0);}
}
else {cerr<<"Wrong Choice!!"; exit(0);}
}
else cerr<<"Wrong Choice!!"; exit(0);
if(cod==1){codfee=0;} else {codfee=0;}
break;
case 8: if(city==1)
{if (w<=500){logfee=45;}
else if(w>=501 && w<=1000){logfee=45+(9*(40));}
else if(w>=1001 && w<=1500){logfee=45+(2*(40));}
else if(w>=1501 && w<=2000){logfee=45+(3*(40));}
else if(w>=2001 && w<=2500){logfee=45+(4*(40));}
else if(w>=2501 && w<=3000){logfee=45+(5*(40));}
else if(w>=3001 && w<=3500){logfee=45+(6*(40));}
else if(w>=3501 && w<=4000){logfee=45+(7*(40));}
else if(w>=4001 && w<=4500){logfee=45+(8*(40));}
else if(w>=4501 && w<=5000){logfee=45+(9*(40));}
else if(w<=5001){cout<<"Contact Customer Care!!";
cout<<"Press 1 to Continue or Press 2 to Try Again Later";
cin>>choice1;
if(choice1==1){logfee=0; break;}
else if(!choice1==1){cerr<<"Wrong Choice!!"; exit(0);}
}
else {cerr<<"Wrong Choice!!"; exit(0);}
}
else if(city==2)
{if (w<=500){logfee=65;}
else if(w>=501 && w<=1000){logfee=65+(1*(60));}
else if(w>=1001 && w<=1500){logfee=65+(2*(60));}
else if(w>=1501 && w<=2000){logfee=65+(3*(60));}
else if(w>=2001 && w<=2500){logfee=65+(4*(60));}
else if(w>=2501 && w<=3000){logfee=65+(5*(60));}
else if(w>=3001 && w<=3500){logfee=65+(6*(60));}
else if(w>=3501 && w<=4000){logfee=65+(7*(60));}
else if(w>=4001 && w<=4500){logfee=65+(8*(60));}
else if(w>=4501 && w<=5000){logfee=65+(9*(60));}
else if(w<=5001){cout<<"Contact Customer Care!!";
cout<<"Press 1 to Continue or Press 2 to Try Again Later";
cin>>choice1;
if(choice1==1){logfee=0;}
else if(!choice1==1){cerr<<"Wrong Choice!!"; exit(0);}
}
else {cerr<<"Wrong Choice!!"; exit(0);}
}
else cerr<<"Wrong Choice!!"; exit(0);
if(cod==1){codfee=20;} else {codfee=0;}
break;
case 9: if(city==1)
{if (w<=500){logfee=47;}
else if(w>=501 && w<=1000){logfee=47+(1*(50));}
else if(w>=1001 && w<=1500){logfee=47+(2*(50));}
else if(w>=1501 && w<=2000){logfee=47+(3*(50));}
else if(w>=2001 && w<=2500){logfee=47+(4*(50));}
else if(w>=2501 && w<=3000){logfee=47+(5*(50));}
else if(w>=3001 && w<=3500){logfee=47+(6*(50));}
else if(w>=3501 && w<=4000){logfee=47+(7*(50));}
else if(w>=4001 && w<=4500){logfee=47+(8*(50));}
else if(w>=4501 && w<=5000){logfee=47+(9*(50));}
else if(w<=5001){cout<<"Contact Customer Care!!";
cout<<"Press 1 to Continue or Press 2 to Try Again Later";
cin>>choice1;
if(choice1==1){logfee=0;}
else if(!choice1==1){cerr<<"Wrong Choice!!"; exit(0);}
}
else {cerr<<"Wrong Choice!!"; exit(0);}
}
else if(city==2)
{if (w<=500){logfee=65; break;}
else if(w>=501 && w<=1000){logfee=65+(1*(70));}
else if(w>=1001 && w<=1500){logfee=65+(2*(70));}
else if(w>=1501 && w<=2000){logfee=65+(3*(70));}
else if(w>=2001 && w<=2500){logfee=65+(4*(70));}
else if(w>=2501 && w<=3000){logfee=65+(5*(70));}
else if(w>=3001 && w<=3500){logfee=65+(6*(70));}
else if(w>=3501 && w<=4000){logfee=65+(7*(70));}
else if(w>=4001 && w<=4500){logfee=65+(8*(70));}
else if(w>=4501 && w<=5000){logfee=65+(9*(70));}
else if(w<=5001){cout<<"Contact Customer Care!!";
cout<<"Press 1 to Continue or Press 2 to Try Again Later";
cin>>choice1;
if(choice1==1){logfee=0;}
else if(!choice1==1){cerr<<"Wrong Choice!!"; exit(0);}
}
else {cerr<<"Wrong Choice!!"; exit(0);}
}
else {cerr<<"Wrong Choice!!"; exit(0);}
if(cod==1){codfee=30;} else {codfee=0;}
break;
default : cerr<<"Wrong Choice!!"; exit(0);}
return logfee;
}
float restfee(int wb,int sp)
{
switch(wb)
{ case 1: trfee=(1*sp)/100;
mkpfee=(1.5*sp)/100;
break;
case 2: trfee=(3.2*sp)/100;
mkpfee=(1.5*sp)/100;
break;
case 3: trfee=(1*sp)/100;
mkpfee=(0.8*sp)/100;
break;
case 4: trfee=(3*sp)/100;
mkpfee=(1.4*sp)/100;
break;
case 5: trfee=(4.5*sp)/100;
mkpfee=5;
break;
case 6: trfee=0;
mkpfee=(1.5*sp)/100;
break;
default : cerr<<"Wrong Choice!!";
exit(0);
}
a=trfee;
b=mkpfee;
return a,b;
}
int pkf(int w)
{
if(w<=1000){pkfee=20;}
else
if(w>1000){pkfee=40;} else {exit(0);}
x=pkfee;
return x;
}
float calculator(float sp)
{
exp=x+b+fvfee+a+logfee+codfee;
tax=(14.5*sp)/100;
cout<<"Tax - "<<tax;
texp=exp+tax;
total=sp-texp;
t=total;
dedc=(t/sp)*100;
inhand=100-dedc;
}
void categdisplay(int category)
{
switch(category)
{case 1:strcpy(categname,"Baby & Mom");
break;
case 2:strcpy(categname,"Books & Magazines");
break;
case 3:strcpy(categname,"Cameras & Optics");
break;
case 4:strcpy(categname,"Automotive");
break;
case 5:strcpy(categname,"Charity");
break;
case 6:strcpy(categname,"Clothing & Accessories");
break;
case 7:strcpy(categname,"Coins & Notes");
break;
case 8:strcpy(categname,"Collectibles");
break;
case 9:strcpy(categname,"Fitness & Sports");
break;
case 10:strcpy(categname,"Fragrances, Beauty & Health");
break;
case 11:strcpy(categname,"Fun Stuff");
break;
case 12:strcpy(categname,"Games & Accessories");
break;
case 13:strcpy(categname,"Home and Living");
break;
case 14:strcpy(categname,"Home & Kitchen Appliances");
break;
case 15:strcpy(categname,"Jewellery & Precious Coins");
break;
case 16:strcpy(categname,"Kitchen & Dining");
break;
case 17:strcpy(categname,"Laptops & Computer Peripherals");
break;
case 18:strcpy(categname,"LCD, LED & Televisions");
break;
case 19:strcpy(categname,"Memory Cards, Pen Drives & HDD");
break;
case 20:strcpy(categname,"Mobile Accessories");
break;
case 21:strcpy(categname,"Mobile Phones");
break;
case 22:strcpy(categname,"Gaming Consoles");
break;
case 23:strcpy(categname,"Movies & Music");
break;
case 24:strcpy(categname,"Musical Instruments");
break;
case 25:strcpy(categname,"Services & Real Estate");
break;
case 26:strcpy(categname,"Shoes");
break;
case 27:strcpy(categname,"Stamps");
break;
case 28:strcpy(categname,"Stationery & Office Supplies");
break;
case 29:strcpy(categname,"Tablets & Accessories");
break;
case 30:strcpy(categname,"Hardware & Electricals");
break;
case 31:strcpy(categname,"Toys, Games & School Supplies");
break;
case 32:strcpy(categname,"Travel");
break;
case 33:strcpy(categname,"Watches");
break;
case 34:strcpy(categname,"Warranty Services");
break;
case 35:strcpy(categname,"Wearable Devices");
break;
case 36:strcpy(categname,"Audio & Home Entertainment");
break;
case 37:strcpy(categname,"Everything Else");
break;
default:cerr<<"Wrong Choice!!"; exit(0);}
}
}ex;
class Datafile{
public:
int x,y,z,i;
void input(){
int ch1;
fstream fin("Seller.txt",ios::out | ios::in | ios::app);
if(!fin){exit(0);}
/*seekg
while(!fin.eof())
{
fin>>z;
c[i]=z;
i++;
}*/
cout<<"Enter Unique ID";
cin>>ch1;
if(c[i]==ch1){cout<<"Duplicate Input"; exit(0);} else {
fin.close();
cout<<"Enter the category number corresponding to its serial number"<<endl<<"1. Baby & Mom"<<endl<<"2. Books & Magazines"<<endl<<"3. Cameras & Optics"<<endl<<"4. Automotive"<<endl<<"5. charity"<<endl<<
"6. Clothing & Accessories"<<endl<<"7. Coins & Notes"<<endl<<"8. Collectibles"<<endl<<"9. Fitness & Sports"<<endl<<"10. Fragrances, Beauty & Health"<<endl;
cout<<"11. Fun Stuff"<<endl<<"12. Games & Accessories"<<endl<<"13. Home and Living"<<endl<<"14. Home & Kitchen Appliances"<<endl<<"15. Jewellery & Precious Coins"<<endl<<"16. Kitchen & Dining"<<endl<<"17. Laptops & Computer Peripherals"<<endl<<"18. LCD, LED & Televisions"<<endl<<"19. Memory Cards, Pen Drives & HDD"<<endl;
cout<<"20. Mobile Accessories"<<endl<<"21. Mobile Phones"<<endl<<"22. Gaming Consoles"<<endl<<"23. Movies & Music"<<endl<<"24. Musical Instruments"<<endl<<"25. Services & Real Estate"<<endl<<"26. Shoes"<<endl<<"27. Stamps"<<endl<<"28. Stationery & Office Supplies"<<endl<<"29. Tablets & Accessories"<<endl;
cout<<"30. Hardware & Electricals"<<endl<<"31. Toys, Games & School Supplies"<<endl<<"32. Travel"<<endl<<"33. Watches"<<endl<<"34. Warranty Services"<<endl<<"35. Wearable Devices"<<endl<<"36. Audio & Home Entertainment"<<endl<<"37. Everything Else"<<endl;
cin>>ex.category;
cout<<"Enter the Number corresponding to the Name of the Website the prouduct is sold on -"<<endl<<"1. Flipkart"<<endl<<"2. SnapDeal"<<endl<<"3. Amazon"<<endl<<"4. PayTM"<<endl<<"5. eBay"<<endl<<"6. ShopClues"<<endl;
cin>>ex.wb;
cout<<"What is the Selling Price Inclusive of all discounts and shipping charges? - ";
cin>>ex.sp;
cout<<"What is the Length, Breadth & Height of the Package (in Cms)?- "<<endl;
cin>>ex.l;
cout<<"X";
cin>>ex.b;
cout<<"X";
cin>>ex.h;
ex.w=(ex.l*ex.b*ex.h)/5;
cout<<endl<<"Press 1 for COD orders or Press 2 for Non COD orders - "<<endl;
cin>>ex.cod;
cout<<endl<<"Press 1 for Shipments within the City or Press 2 for Shipments Outside the City - ";
cin>>ex.city;
cout<<"Which Logistics is Used for the Shipment - "<<endl<<"1. BlueDart"<<endl<<"2. FedEx"<<endl<<"3. Delhivery"<<endl<<"4. DTDC/FirstFlight"<<endl<< "5. Ecom Express";
cout<<endl<<"6. India Post"<<endl<< "7. ATS"<<endl<< "8. Ekart"<<endl<<"9. Aramex"<<endl;
cin>>ex.log;
ex.categdisplay(ex.category);
ex.logistics(ex.city,ex.w,ex.cod,ex.log);
ex.finalvfee();
ex.restfee(ex.wb,ex.sp);
ex.pkf(ex.w);
ex.calculator(ex.sp);
fin<<endl<<endl<<" eCommerce Seller Fees Calculator"<<endl<<endl;
fin<<"Unique Custom ID"<<ch1<<endl;
fin<<"Category - "; fin<<ex.categname;
fin<<endl<<"Website - "<<wbname[ex.wb];
fin<<endl<<"Courier Company(Logistics) - "<<logname[ex.wb];
fin<<endl<<"Weight - "<<ex.w;
fin<<endl<<"MarketPlace Fee - "<<ex.a;
fin<<endl<<"Transaction Fee - "<<ex.b;
fin<<endl<<"Final value Fee(Based on Category) Fee - "<<ex.fvfee;
fin<<endl<<"Logistics Fee - "<<ex.logfee;
fin<<endl<<" Packaging Fee - "<<ex.x<<endl;
fin<<endl<<"The Total In Hand Amount after 14.5 % Tax is - "<<ex.t<<endl;
fin<<endl<<" Total Deduction Percentage is - "<<setprecision(4)<<ex.dedc<<" %"<<endl;
fin<<endl<<" Total In-Hand Percentage is - "<<setprecision(4)<<ex.inhand<<" %"<<endl;
fin.close();
}
getch();
mainmenu();
}
void output(){
cout<<endl<<endl;
int found=0;
int ch2;
ifstream ff("Seller.txt");
if(!ff){exit(0);}
ff.seekg(85);
while(!ff.eof()){
ff.read((char*)&ex,sizeof(ex));
ff>>y;
b[i]=y; }
cout<<endl<<"Enter a Unique Custom ID"<<endl<<endl;
cin>>ch2;
ff.close();
ifstream fin("Seller.txt");
if(!fin){exit(0);}
cout<<"----Search Result----";
while(!fin.eof()){
fin.read((char*)&ex,sizeof(ex));
if(b[i]==ch2){
cout<<endl<<" Category - "; cout<<ex.categname;
cout<<endl<<" Website - "; puts(wbname[ex.wb]);
cout<<endl<<" Courier Company(Logistics) - "; puts(logname[ex.wb]);
cout<<endl<<" Weight - "<<ex.w;
cout<<endl<<" MarketPlace Fee - "<<ex.b;
cout<<endl<<" Transaction Fee - "<<ex.a;
cout<<endl<<" Final value Fee(Based on Category) Fee - "<<ex.fvfee;
cout <<endl<<" Logistics Fee - "<<ex.logfee;
cout<<endl<<" Packaging Fee - "<<ex.x<<endl;
cout<<endl<<" The Total In Hand Amount after 14.5 % Tax is - "<<"INR "<<ex.t<<endl;
cout<<endl<<" Total Deduction Percentage is - "<<setprecision(4)<<ex.dedc<<" %"<<endl;
cout<<endl<<" Total In-Hand Percentage is - "<<setprecision(4)<<ex.inhand<<" %"<<endl;
found=1;
break;
}
} if(found==0){cout<<"\n\n\t----Not found----";getch();mainmenu();}
fin.close();
getch();
mainmenu();
}
void del(){ int i;
ifstream fio("Seller.txt");
ofstream file("temp.txt");
char found ='f',confirm = 'n';
int ch2;
fio.seekg(85);
while(!fio.eof())
{
fio.read((char*)&ex,sizeof(ex));
fio>>x;
a[i]=x;
i++;
}
cout<<"Enter a Unique Custom ID"<<endl<<endl;
cin>>ch2;
while(!fio.eof()){
fio.read((char*)&ex,sizeof(ex));
if(a[i]==ch2){
output();
found='t';
cout<<"Are you sure, you want to delete this Record? (y/n)...";
cin>>confirm;
if(confirm=='n'){file.write((char*)&ex,sizeof(ex));}
}
else{file.write((char*)&ex,sizeof(ex));}
}
if(found=='f'){cout<<"Record not Found!!\n"; mainmenu();}
fio.close();
file.close();
remove("Seller.txt");
if(!fio){
rename("temp.txt","Seller.txt");
cout<<"Record Successfully Deleted...";}
else {exit(0);}
getch();
mainmenu();
}
int mainmenu()
{
int g;
int ch;
cout<<endl<<endl<<" eCommerce Seller Fees Calculator"<<endl<<endl;
cout<<"1=>Calculate / Input"<<endl<<"2=>Show"<<endl<<"3=>Delete"<<endl<<"4=>Show all Unique Custom IDs"<<endl<<"5=>Exit";
cin>>g;
if(g==1){input();}
else if (g==2){output();}
else if(g==3){del();}
else if(g==4){ifstream outfout;
outfout.open("Seller.txt");
outfout.read((char*)&ex,sizeof(ex));
while(!outfout.eof())
{
outfout>>ch;
cout<<endl<<ch<<endl;
}
mainmenu();
outfout.close();}
else exit(0);
return 0;
}
}eg;
int main()
{ eg.mainmenu();
cout<<" Note: Calculations are not 100% accurate. These are approximate figures only and may vary based on exact product weight and packaging dimensions."<<endl<< "Legal : All the Registered TradeMark Names are the properties of their respective Owners/Investors/ShareHolders";
return 0;
}