Challenge

Project 1

#include <iostream>
#include<string.h>
#include<fstream>
using namespace std;

string name1;
string name2;
string name3;
int n,m;
string commodities[100];
int vendors[100][100];

int purchase[100];
fstream data_file;

void ITsupport()
{

cout<<"Enter the Person1 of Commodities to be purchased"<<endl;
cin>>name1;
for(int i=0;i<n;i++)
{
cout<<"Enter no of"<<commodities[i]<<"needed";
cin>>purchase[i];
}
cout<<"Enter the Person2 of Commodities to be purchased"<<endl;
cin>>name2;
for(int i=0;i<n;i++)
{
cout<<"Enter no of"<<commodities[i]<<"needed";
cin>>purchase[i];
}
cout<<"Enter the Person3 of Commodities to be purchased"<<endl;
cin>>name3;
for(int i=0;i<n;i++)
{
cout<<"Enter no of"<<commodities[i]<<"needed";
cin>>purchase[i];
}
}


void vendordetails(){
data_file<<"commodities\t\t"<<"vendor 1\t"<<" Vendors 2"<<endl;
for(int i=0;i<n;i++)
{
data_file<<commodities[i]<<"\t\t\t";
for(int j=0;j<m;j++)
{

data_file<<vendors[i][j]<<"\t\t\t\t";
}
data_file<<endl;
}
}


void totalvalue1()
{
int total[m];
for(int i=0;i<n;i++)
{
data_file<<"Enter no of\t"<<commodities[i]<<"needed\t"<<purchase[i]<<"\n";
}
for(int j=0;j<m;j++)
{
total[j]=0;
}
for(int j=0;j<m;j++)
{
for(int i=0;i<n;i++)
{
total[j]=total[j]+(purchase[i]*vendors[i][j]);
}
cout<<"Total of "<<"Vendor "<<j+1<<"is\t"<<total[j]<<endl;
data_file<<"Total of "<<"Vendor "<<j+1<<"is\t"<<total[j]<<endl;
}

int max=total[0];
for(int i=1;i<m;i++)
{
if(max>total[i])
{
max=total[i];
}
}
cout<<"Vendor with total amount"<<max<<"is best for purchase"<<endl;
data_file<<"Vendor with total amount"<<max<<"is best for purchase"<<endl;
}

void totalvalue2()
{
int total[m];
for(int i=0;i<n;i++)
{
data_file<<"Enter no of\t"<<commodities[i]<<"needed\t"<<purchase[i]<<"\n";
}
for(int j=0;j<m;j++)
{
total[j]=0;
}
for(int j=0;j<m;j++)
{
for(int i=0;i<n;i++)
{
total[j]=total[j]+(purchase[i]*vendors[i][j]);
}
cout<<"Total of "<<"Vendor "<<j+1<<"is\t"<<total[j]<<endl;
data_file<<"Total of "<<"Vendor "<<j+1<<"is\t"<<total[j]<<endl;
}
int max=total[0];
for(int i=1;i<m;i++)
{
if(max>total[i])
{
max=total[i];
}
}
cout<<"Vendor with total amount"<<max<<"is best for purchase"<<endl;
data_file<<"Vendor with total amount"<<max<<"is best for purchase"<<endl;
}

void totalvalue3()
{
int total[m];
for(int i=0;i<n;i++)
{
data_file<<"Enter no of\t"<<commodities[i]<<"needed\t"<<purchase[i]<<"\n";
}
for(int j=0;j<m;j++)
{
total[j]=0;
}
for(int j=0;j<m;j++)
{
for(int i=0;i<n;i++)
{
total[j]=total[j]+(purchase[i]*vendors[i][j]);
}
cout<<"Total of "<<"Vendor "<<j+1<<"is\t"<<total[j]<<endl;
data_file<<"Total of "<<"Vendor "<<j+1<<"is\t"<<total[j]<<endl;
}
int max=total[0];
for(int i=1;i<m;i++)
{
if(max>total[i])
{
max=total[i];
}
}
cout<<"Vendor with total amount"<<max<<"is best for purchase"<<endl;
data_file<<"Vendor with total amount"<<max<<"is best for purchase"<<endl;
}
int main()
{
data_file.open("my file",ios::out);
cout<<"enter no of commodities"<<endl;
cin>>n;
cout<<"enter no of vendors";
cin>>m;
cout<<"Enter the commodities";
for(int i=0;i<n;i++)
{
cin>>commodities[i];
}
cout<<"enter the details of vendors";
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cin>>vendors[i][j];
}
}
ITsupport();
vendordetails();
data_file<<"IT support1 who wants Commodities to be purchased "<<name1<<endl;
totalvalue1();
data_file<<"IT support2 who wants Commodities to be purchased"<<name2<<endl;
totalvalue2();
data_file<<"IT support3 who wants Commodities to be purchased "<<name3<<endl;
totalvalue3();

return 0;
}

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.