Skip to content
This repository has been archived by the owner on Jun 22, 2020. It is now read-only.

team#2 #26

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions team#2 - Food Technology/afms.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include<stdio.h>

void main(){

}
63 changes: 63 additions & 0 deletions team#2 - Food Technology/booth.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#include<iostream>
#include<fstream>
#include<stdlib.h>

using namespace std;

class booth{
private:
int f_id;
float wt;
float grade;
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;
}
void process(){
int x=grade;
switch(x){
case 1: price=wt*3/5*100;
break;
case 2: price=wt*4/5*100;
break;
case 3: price=wt*100;
break;
default:cout<<"wrong input of quality ";
break;

}
cout<<"Payment to farmer: "<<price;

}

};
int main(){
char a;
while(1){
system("cls");
cout<<"Do you want to enter data(Y/N): ";
cin>>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;
}
103 changes: 103 additions & 0 deletions team#2 - Food Technology/consumer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#include<iostream>
#include<fstream>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>

using namespace std;

class consumer{
private:
int f_id;
float wt;
float grade;
float price;
float dis,c_price;
float c_wt;

public:
int ffun(){
return f_id;
}
float gfun(){
return grade;
}
void out(){
cout<<"farmer ID "<<f_id <<endl;
printf("Weight of crop in Quintal%.2f\n",wt);
cout<<"Quality of crop: "<<grade<<endl;
// printf("%.2f\n",price);
}
void process(){
cout << "Please enter the distance from booth in KM ";
cin>>dis;
cout<<endl << "Enter crop amount required in Quintal";
cin>>c_wt;
if(wt>=c_wt){
if(dis<=500)
c_price=price+2400+(dis*c_wt*5);
else
c_price=price+2400+(dis*c_wt*3);
cout<<"Price to be paid: "<<c_price<<endl<<endl;
}
else{
cout<< "Insufficient stock";
}
system("pause");


}

};
int main(){
int x,f;
float g;
while(1){
ifstream fin("data.dat",ios::in);
system("cls");
cout<<"1> Display whole list: \n2>Search by farmer ID:\n3>Search by Grade:\n4>Exit \n\nEnter the option number you want to execute: ";
cin>>x;
switch(x){
case(1):
while(fin){
consumer c;
fin.read((char*)&c,sizeof(c));
c.out();
c.process();
}
break;
case(2):cout<<"Enter farmer id to be searched: ";
cin>>f;
while(fin){
consumer c;
fin.read((char*)&c,sizeof(c));

if(c.ffun()==f){
c.out();
c.process();
}
}
break;
case(3):cout<<"Enter quality grade to be searched: ";
cin>>g;
while(fin){
consumer c;
fin.read((char*)&c,sizeof(c));
if(c.gfun()==g){
c.out();
c.process();
}
}
break;
case(4):cout<<"Exiting... ";
exit(1);
break;
default:cout<<"Wrong input ";
break;
}
fin.close();
}


return 0;
}