diff --git a/ab.c b/ab.c new file mode 100644 index 0000000..3bb1711 --- /dev/null +++ b/ab.c @@ -0,0 +1,7 @@ +#include +#include +int main() +{ + printf("hello world"); +} + diff --git a/booth.cpp b/booth.cpp new file mode 100644 index 0000000..35844bc --- /dev/null +++ b/booth.cpp @@ -0,0 +1,66 @@ +#include +#include +#include + +using namespace std; + +class booth{ + private: + float f_id; + float wt; + float grade; + float rate; + float price; + public: + void in(){ + cout<<"Enter farmer id: "; + cin>>f_id; + cout<<"Enter weight in quintal of crop: "; + cin>>wt; + cout<<"Enter its quality(between 1-3): "; + cin>>grade; + cout<<"Enter rate: "; + cin>>rate; + } + void process(){ + int x=grade; + switch(x){ + case 1: price=wt*3/5*rate; + break; + case 2: price=wt*4/5*rate; + break; + case 3: price=wt*rate; + break; + default:cout<<"wrong input of quality "; + break; + + } + cout<<"Payment to farmer: "<>a; + if(a=='y'||a=='Y') + { + booth b; + b.in(); + b.process(); + ofstream fout; + fout.open("data.dat",ios::out|ios::binary|ios::app); + fout.write((char*)&b, sizeof (b)); + fout.close(); + } + else if(a=='n'||a=='N') + exit(1); + else + cout<<"Wrong input, try again"; + system("pause"); + } + return 0; +}