The goal of this program is to determine the following The h

The goal of this program is to determine the following: The highest costing quarter (combine all 5 products) and the associated Total Material, Labor, Transportation, and overall cost. The highest costing product for the year and the associated Material, Labor. Transportation, and Total for that product. Include required documentation and header for the problem. The output of your program should look like the test case displayed below with the same spacing, indentations, and number of significant digits.

Solution

#include <stdio.h>

int main()
{
int i,n,mat[5],lab[5],trans[5],q1[5],q2[5],q3[5],q4[5],qm1[5],qm2[5],qm3[5],qm4[5],ql1[5],ql2[5],ql3[5],ql4[5],qt1[5],qt2[5],qt3[5],qt4[5],quart1[5],quart2[5],quart3[5],quart4[5];
int q1mat=0,q2mat=0,q3mat=0,q4mat=0,q1lab=0,q2lab=0,q3lab=0,q4lab=0,q1trans=0,q2trans=0,q3trans=0,q4trans=0,quat1=0,quat2=0,quat3=0,quat4=0;
int prod1=0,prod2=0,prod3=0,prod4=0,material1=0,material2=0,material3=0,material4=0,labor1=0,labor2=0,labor3=0,labor4=0,trans1=0,trans2=0,trans3=0,trans4=0;
printf(\"enter the no of products\");

scanf(\"%d\",&n);
for(i=1;i<=n;i++) // user giving the input
{
printf(\"Enter the material cost for product %d\ \",i);
scanf(\"%d\",&mat[i]);
printf(\"Enter the labor cost for product %d\ \",i);
scanf(\"%d\",&lab[i]);
printf(\"Enter the material cost for product %d\ \",i);
scanf(\"%d\",&trans[i]);
}
printf(\"enter the quarterly production cost\ \");
for(i=1;i<=n;i++)
{
printf(\"Enter the production cost for product %d in quarter 1\ \",i);
scanf(\"%d\",&q1[i]);
printf(\"Enter the production cost for product %d in quarter 2\ \",i);
scanf(\"%d\",&q2[i]);
printf(\"Enter the production cost for product %d in quarter 3\ \",i);
scanf(\"%d\",&q3[i]);
printf(\"Enter the production cost for product %d in quarter 4\ \",i);
scanf(\"%d\",&q4[i]);
}
  
for(i=1;i<=n;i++) // calculating the material,labor,transportation for individual products
{
qm1[i]=mat[i]*q1[i];
qm2[i]=mat[i]*q2[i];
qm3[i]=mat[i]*q3[i];
qm4[i]=mat[i]*q4[i];
ql1[i]=lab[i]*q1[i];
ql2[i]=lab[i]*q2[i];
ql3[i]=lab[i]*q3[i];
ql4[i]=lab[i]*q3[i];
qt1[i]=trans[i]*q1[i];
qt2[i]=trans[i]*q2[i];
qt3[i]=trans[i]*q3[i];
qt4[i]=trans[i]*q4[i];
  
q1mat=q1mat+qm1[i];
q1lab=q1lab+ql1[i];
q1trans=q1mat+qt1[i];
q2mat=q2mat+qm2[i];
q2lab=q2lab+ql2[i];
q2trans=q2mat+qt2[i];
q3mat=q3mat+qm3[i];
q3lab=q3lab+ql3[i];
q3trans=q3mat+qt3[i];
q4mat=q4mat+qm4[i];
q4lab=q4lab+ql4[i];
q4trans=q4mat+qt4[i];
}
for(i=1;i<=n;i++) //calculating the total cost of a quarter
{
quart1[i]=qm1[i]+ql1[i]+qt1[i];
quart2[i]=qm2[i]+ql2[i]+qt2[i];
quart3[i]=qm3[i]+ql3[i]+qt3[i];
quart4[i]=qm4[i]+ql4[i]+qt4[i];
  
quat1=quat1+quart1[i];
quat2=quat2+quart2[i];
quat3=quat3+quart3[i];
quat4=quat4+quart4[i];
}
for(i=1;i<=n;i++) //calculating the product cost
{
if(i==1)
{
prod1=qm1[i]+qm2[i]+qm3[i]+qm4[i]+ql1[i]+ql2[i]+ql3[i]+ql4[i]+qt1[i]+qt2[i]+qt3[i]+qt4[i];
material1=qm1[i]+qm2[i]+qm3[i]+qm4[i];
labor1=ql1[i]+ql2[i]+ql3[i]+ql4[i];
trans1=qt1[i]+qt2[i]+qt3[i]+qt4[i];
}
if(i==2)
{
prod2=qm1[i]+qm2[i]+qm3[i]+qm4[i]+ql1[i]+ql2[i]+ql3[i]+ql4[i]+qt1[i]+qt2[i]+qt3[i]+qt4[i];
material2=qm1[i]+qm2[i]+qm3[i]+qm4[i];
labor2=ql1[i]+ql2[i]+ql3[i]+ql4[i];
trans2=qt1[i]+qt2[i]+qt3[i]+qt4[i];
}
if(i==3)
{
prod3=qm1[i]+qm2[i]+qm3[i]+qm4[i]+ql1[i]+ql2[i]+ql3[i]+ql4[i]+qt1[i]+qt2[i]+qt3[i]+qt4[i];
material3=qm1[i]+qm2[i]+qm3[i]+qm4[i];
labor3=ql1[i]+ql2[i]+ql3[i]+ql4[i];
trans3=qt1[i]+qt2[i]+qt3[i]+qt4[i];
}
if(i==4)
{
prod4=qm1[i]+qm2[i]+qm3[i]+qm4[i]+ql1[i]+ql2[i]+ql3[i]+ql4[i]+qt1[i]+qt2[i]+qt3[i]+qt4[i];
material4=qm1[i]+qm2[i]+qm3[i]+qm4[i];
labor4=ql1[i]+ql2[i]+ql3[i]+ql4[i];
trans4=qt1[i]+qt2[i]+qt3[i]+qt4[i];
}
if(i==5)
{prod5=qm1[i]+qm2[i]+qm3[i]+qm4[i]+ql1[i]+ql2[i]+ql3[i]+ql4[i]+qt1[i]+qt2[i]+qt3[i]+qt4[i];}
  
  
}
if(quat1>quat2)
{
if(quat1>quat3)
{
if(quat1>quat4)
{
printf(\"Quarter1 is the highest costing quarter\ \");
printf(\"material cost=%d\",q1mat);
printf(\"\ labor cost=%d\",q1lab);
printf(\"\ transportation cost=%d\",q1trans);
printf(\"total cost=%d\",quat1);
}
}
else if(quat2>quat3)
{
if(quat2>quat4)
{
printf(\"Quarter2 is the highest costing quarter\ \");
printf(\"material cost=%d\",q2mat);
printf(\"\ labor cost=%d\",q2lab);
printf(\"\ transportation cost=%d\",q2trans);
printf(\"total cost=%d\",quat2);
}
}
else if(quat3>quat4)
{
printf(\"Quarter3 is the highest costing quarter\ \");
printf(\"material cost=%d\",q3mat);
printf(\"\ labor cost=%d\",q3lab);
printf(\"\ transportation cost=%d\",q3trans);
printf(\"total cost=%d\",quat3);
}
}
else
{
printf(\"Quarter4 is the highest costing quarter\ \");
printf(\"material cost=%d\",q4mat);
printf(\"\ labor cost=%d\",q4lab);
printf(\"\ transportation cost=%d\",q4trans);
printf(\"total cost=%d\",quat4);
}
  
if(prod1>prod2)
{
if(prod1>prod3)
{
if(prod3>prod4)
{
printf(\"Product 1 is the highest costing product\ \");
printf(\"material cost=%d\",material1);
printf(\"\ labor cost=%d\",labor1);
printf(\"\ transportation cost=%d\",trans1);
printf(\"total cost=%d\",prod1);
}
}
else if(quat2>quat3)
{
if(quat2>quat4)
{
printf(\"Product 2 is the highest costing product\ \");
printf(\"material cost=%d\",material2);
printf(\"\ labor cost=%d\",labor2);
printf(\"\ transportation cost=%d\",trans2);
printf(\"total cost=%d\",prod2);
}
}
else if(quat3>quat4)
{
printf(\"Product 3 is the highest costing product\ \");
printf(\"material cost=%d\",material3);
printf(\"\ labor cost=%d\",labor3);
printf(\"\ transportation cost=%d\",trans3);
printf(\"total cost=%d\",prod3);
}
}
else
{
printf(\"Product 4 is the highest costing product\ \");
printf(\"material cost=%d\",material4);
printf(\"\ labor cost=%d\",labor4);
printf(\"\ transportation cost=%d\",trans4);
printf(\"total cost=%d\",prod4);
}
  
}
  
return 0;
  
}

 The goal of this program is to determine the following: The highest costing quarter (combine all 5 products) and the associated Total Material, Labor, Transpor
 The goal of this program is to determine the following: The highest costing quarter (combine all 5 products) and the associated Total Material, Labor, Transpor
 The goal of this program is to determine the following: The highest costing quarter (combine all 5 products) and the associated Total Material, Labor, Transpor
 The goal of this program is to determine the following: The highest costing quarter (combine all 5 products) and the associated Total Material, Labor, Transpor

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site