Answer to Question #212274 in C++ for fazily

Question #212274

Write a function using C++ statements called PrintReport() which takes three float arrays (valuel, value2, value3) and an integer (as the size of the array) as parameters. The method prints the report as given below.

Sample Output:

Day Machine A Machine B Machine C Minimum Maximum Total Average

1 15.5        50       35.5    A B  101 33.66

2 25.5        45.5  65 A C  136 45.33

3 27.5        25.5  71   B C 124 41.33

4 60.5         18       74.5   B C 153 51

Note: Should use functions already defined to find minimum, maximum, total and average.


1
Expert's answer
2021-06-30T13:45:00-0400
#include<iostream>
using namespace std;


char MaximumMachine(float value1, float value2, float value3){
char x;
if(value1>value2 && value1 >value3){
	x= 'A';
}
else if(value2>value1 && value2>value3){
	x ='B';
}
else if(value3>value1 && value3>value2){
	x ='C';
}
return x;	
}




char MinimumMachine(float value1, float value2, float value3){
char x;
if(value1<value2 && value1 <value3){
	x= 'A';
}
else if(value2<value1 && value2<value3){
	x ='B';
}
else if(value3<value1 && value3<value2){
	x ='C';
}
return x;	
}


float total(float arr[], int N){
	int i;
	float sum =0.0;
	for( i<0; i<N; i++){
		sum += arr[i];
	}
	return sum;
}


double average(float arr[] , int N){
	double sum = 0.0;
	int i;
	for( i<0; i<N; i++){
		sum += arr[i];
	}
	return sum/N;
		
}//Answer to the question
void PrintReport(float arr[] , int N){
	cout<<"Day\tMachine A\t Machine B\t Machine C\t Minimum\t Maximum\t Total\t Average\n";
	cout<<1<<"\t"<<arr[0]<<"\t\t"<<arr[1]<<"\t\t"<<arr[2]<<"\t\t"<<MinimumMachine(arr[0],arr[1], arr[2])<<"\t\t";
	cout<<MaximumMachine(arr[0],arr[1], arr[2])<<"\t\t"<<total(arr,3)<<"\t";
	cout<<average(arr,3)<<"\t";
}
//Main() function to test the PrintReport() function
int main(){
	
float arr[3] = { 15.5,50,35.5};
PrintReport(arr, 3);	
}

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