Project 1
Ramu, Raju and Shyam are working in an IT support team in an Organisation. An organisation has several departments which work on different projects. Due to covid organisations had to restructure their finances as work from home should be implemented across the organisation. There would be a number of workstations to be purchased in order to support employees work without any hindrance and achieve the project deliverables.
As a part of their duty, each of them (Ramu,Raju,Shyam) are given responsibilities to maintain the project budget and reduce the stationary expenses made by various departments. Each department expenses depends on the number of people working in the project, cubicles desk and cubicle chairs allocated for each person, Workstation allocation which includes Desktop/Laptop, headset and stationary items such as Notepad, Pen, Pencil, Stapler, A4 Sheets for printouts of project material etc. One or two printers would be allocated to departments based on the project size. Ramu, Raju and Shyam are required to maintain these commodities and bring down the project expense cost as the stationary items would not be required as employees would be working from home. Hence, the expenses on stationery should be transferred to the workstation expenses. Ramu is responsible for Department ADAS, Raju is the IT support contact for Department Electro, Shyam is the IT SPOC(single point of contact ) for Department Connexion. The manager of each department has shared the number of commodities required to the IT SPOC’s and they had approached two vendors who had given their reasonable quotations for the commodities. However, the finance department had asked the IT support team to purchase within the given budget and reduce the expenses as discussed above.
Say there are two vendors from whom the commodities/workstations are ordered, the individual prices and desired quantities of commodities are given in the following tables.
|
Person/Number of Commodities to be brought |
Laptop |
Mouse |
Headset |
Laptop Bag |
Adapter |
|
Ramu |
5 |
15 |
10 |
5 |
20 |
|
Raju |
10 |
10 |
25 |
10 |
15 |
|
Shyam |
3 |
5 |
6 |
3 |
10 |
|
Commodity/Commodity cost |
Vendor1 |
Vendor2 |
|
Laptop |
45000 |
43000 |
|
Mouse |
1500 |
1200 |
|
Headset |
2500 |
3000 |
|
Laptop Bag |
1200 |
1000 |
|
Adapter |
1600 |
1500 |
Taking the above mentioned data as a sample, Find the best vendor from whom the purchases can be made based on the number of commodities and respective prices to pay a reasonable price.
Now, using array of pointers or dynamically using double pointers dynamically allocate memory for every row in the following arrays:
-
Array one ->commodities
-
Array two ->Vendors
-
The Result will also be a two dimensional array or a double pointer.
Also, have a menu listed for prompting the user input to enter the commodities and vendors. The menu looks like
-
Enter Commodities to be purchased
-
Enter Vendor quotations
-
Exit
solution code:-
#include <iostream> // headerfile
#include<fstream>
#include<cstring>
#define M 5
#define N 3
using namespace std;
int main()
{
string* A=new string[M*N]; //dynamically allocated memory of size M*new
int Laptop[3],Mouse[3],Headset[3],Laptop_bag[3],Adaptor[3]; //arrey declairation for comodities
int s,k;
int vendor1_total,vendor2_total; //arrey declairation for vendor
int num[2][2];
ofstream outdata;
outdata.open("project_1_sample.txt");
start:
cout<<"select from below menu: \n"<<endl;
cout<<"1.enter to select the comdities to be purchesed: \n"<<endl;
cout<<"2.enter to select the cvendor quotation: \n"<<endl;
cout<<"3.enter to find the best vendor(only select when you have enter the comdities and vendor data: \n"<<endl;
cout<<"0.Exit: \n"<<endl;
cin>>s;
outdata<<"selected option"<<endl;
outdata<<s<<endl;
switch(s)
{
case 1:
cout<<"please enter the name of comodities :"<<endl;
cout<<endl;
outdata<<"\n name of the comodities"<<endl;
for(int i=0; i<M; i++)
{
for (int j=0; j<1; j++)
{
cin>>*(A + i*N + j);
outdata<<*(A + i*N + j)<<endl;
}
}
outdata<<endl;
cout<<endl;
goto start;
break;
case 2:
cout<<"enter the vendor 1 quotation:"<<endl;
cout<<endl;
outdata<<"\n vendor 1 quotation as per commodities enter"<<endl;
for(int i=0; i<M;i++)
{
for (int j=1;j<2;j++)
{
cin>>*(A + i*N + j);
outdata<<*(A + i*N + j)<<endl;
}
}
cout<<"enter the vendor 2 quotation:"<<endl;
cout<<endl;
outdata<<"\n vendor 2 quotation as per commodities enter"<<endl;
for(int i=0; i<M;i++)
{
for (int j=2;j<3;j++)
{
cin>>*(A + i*N + j);
outdata<<*(A + i*N + j)<<endl;
}
}
goto start;
break;
case 3:
cout<<"enter the number of laptop 'ramu' 'raju' 'shyam' wants to buy\n"<<endl;
cout<<endl;
outdata<<"number of laptop 'ramu' 'raju' and shyam bought"<<endl;
for(int i=0;i<3;i++)
{
cin>>Laptop[i]; outdata<<Laptop[i]<<endl;
}
cout<<"\n Enter the number of mouse 'ramu','raju',and 'shyam' want to bought";
cout<<endl;
cout<<"\n number of mouse 'ramu','raju',and 'shyam' want to bought";
cout<<endl;
for(int i=0;i<3;i++)
{cin>>Mouse[i];outdata<<Mouse[i]<<endl;}
cout<<"\n Enter the number of headst 'ramu','raju',and 'shyam' want to bought";
cout<<endl;
cout<<"\n number of headset 'ramu','raju',and 'shyam' want to bought";
cout<<endl;
for(int i=0;i<3;i++)
{cin>>Headset[i];outdata<<Headset[i]<<endl;}
cout<<"\n Enter the number of Laptop_bag 'ramu','raju',and 'shyam' want to bought";
cout<<endl;
cout<<"\n number of Laptop_bag 'ramu','raju',and 'shyam' want to bought";
cout<<endl;
for(int i=0;i<3;i++)
{cin>>Laptop_bag[i];outdata<<Mouse[i]<<endl;}
cout<<"\n Enter the number of Adaptor 'ramu','raju',and 'shyam' want to bought";
cout<<endl;
cout<<"\n number of Adaptor 'ramu','raju',and 'shyam' want to bought";
cout<<endl;
for(int i=0;i<3;i++)
{cin>>Adaptor[i];outdata<<Mouse[i]<<endl;}
for(int i=0;i<M;i++)
{
for(int j=1;j<3;j++)
{
num[i][j]=stoi(*(A+i*N+j));
}
}
for(int k=0; k<3; k++)
{
if(k==0)
{
cout<<"the best vendor for ramu is:-";
}
else if(k==1)
{
cout<<"the best vendor for raju is:-";
}
else
{
cout<<"the best vendor for shyam is:-";
}
}
vendor1_total=Laptop[k]*num[0][1]+Mouse[k]*num[1][1]+Headset[k]*num[2][1]+Laptop_bag[k]*num[3][1]+Adaptor[k]*num[4][1];
vendor2_total=Laptop[k]*num[0][2]+Mouse[k]*num[1][2]+Headset[k]*num[2][2]+Laptop_bag[k]*num[3][2]+Adaptor[k]*num[4][2];;
if(vendor1_total<vendor2_total)
{
cout<<"vendor1"<<endl;
}
else
{
cout<<"vendor2"<<endl;
}
break;
case 0:
exit(0);
default:
cout<<"Invalid selection:\n"<<endl;
goto start;
}
return 0;
}
output:-


