From 5c6022cc61b8689e6c5fca7978913268d1e2a7bb Mon Sep 17 00:00:00 2001 From: Sherlock-dev <56157389+Sherlock-dev@users.noreply.github.com> Date: Sun, 13 Oct 2019 22:12:43 +0530 Subject: [PATCH 1/2] string func --- string.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 string.c diff --git a/string.c b/string.c new file mode 100644 index 0000000..239e84d --- /dev/null +++ b/string.c @@ -0,0 +1,17 @@ +#include +void main() +{ + char st[100],c; + int i =0; + printf("Enter a string with less than 100 characters\n"); + dos + { c = getchar(); + st[i]=c; + i++; + }while(c!='\n'); + for(int j = 0;j<(i-1);j++) + printf("%-*.*s\n",(i-1),(j+1),st); + for(int j = 1;j<(i-1);j++) + printf("%-*.*s\n",(i-1),(i-1-j),st); + +} From 7a30c9443970e8ccb2f9d045837671eb8186fabf Mon Sep 17 00:00:00 2001 From: ashish336652 <51014196+ashish336652@users.noreply.github.com> Date: Sun, 13 Oct 2019 22:55:43 +0530 Subject: [PATCH 2/2] booth.cpp --- booth.cpp | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 booth.cpp 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; +}