Answer to Question #212286 in C++ for fazily

Question #212286

C++ PROGRAMMING

The "TRC Institute" records and monitors performance of three (3) machines over a period of four (4) days (l to 4) as shown in the Table 1, 2 and 3 respectively. The production ranges between 15.5 and 75.5 

Table 1- Machine "A" Production

Day 1 2 3 4

Array index 0 1 2 3

Production 15.5 25.5 27.5 60.5

Table 2- Machine "B" Production

Day 1 2 3 4

Array index 0 1 2 3

Production 50 45.5 25.5 18

Table 3- Machine "C" Production

Day 1 2 3 4

Array index 1 2 3 4

Production 35.5 65 71 74.5

Implement the main method of a C++ program to do the followings.

1 . Create 3 float arrays with the names machine A, machine B and machine C. The arrays are of size 4.

2.Insert machine A, B and C production to the respective array using the function InputProduction()

3. Print chart of all four (4) days by using the function PrintChart().

4. Print the report using the function PrintReport()


1
Expert's answer
2021-07-03T04:49:02-0400
using namespace std;


#include <stdio.h>
//What is the output if bilangan is 4 ?






#define NO_OF_DAYS	4




void InputProduction(float *m, float Prod[])
{
	float u;
	int k=0;
	while(k<NO_OF_DAYS) 
	{
		*(m+k) = Prod[k];
		k++;
	}	
}


void PrintChart(float *m, char c)
{
	int k=0;
	cout<<"\n\nProduction Chart - Machine - "<<c;
	while(k<NO_OF_DAYS)
	{
		cout<<"\nProduction of Day - "<<(k+1)<<" = "<<*(m+k);
		k++;
	}
}


void PrintReport(float *a, float *b, float *c)
{
	int k=0;
	cout<<"\n\n\t\tDays\t\tMachine-A\tMachine-B\tMachine-C\n";
	while(k<NO_OF_DAYS)
	{
		cout<<"\t\t"<<(k+1)<<"\t\t"<<*(a+k)<<"\t\t"<<*(b+k)<<"\t\t"<<*(c+k)<<endl;
		k++;
	}
}




main(void)
{
	float temp[NO_OF_DAYS];
	float Machine_A[NO_OF_DAYS], Machine_B[NO_OF_DAYS], Machine_C[NO_OF_DAYS];
	float *ptrA,*ptrB,*ptrC;
	ptrA = Machine_A;
	ptrB = Machine_B;
	ptrC = Machine_C;
	
	temp[0] = 15.5; temp[1]=25.5; temp[2]=27.5; temp[3]=60.5;
	InputProduction(ptrA,&temp[0]);
	PrintChart(ptrA,'A');


	temp[0] = 50; temp[1]=45.5; temp[2]=25.5; temp[3]=18;
	InputProduction(ptrB,&temp[0]);
	PrintChart(ptrB,'B');


	temp[0] = 35.5; temp[1]=65; temp[2]=71; temp[3]=74.5;
	InputProduction(ptrC,&temp[0]);
	PrintChart(ptrC,'C');
	
	PrintReport(ptrA,ptrB,ptrC);
	return(0);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS