Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PROGRAM USING C++ Problem: The company, HeatTransfer, for which your analyzed da

ID: 3605758 • Letter: P

Question

PROGRAM USING C++

Problem: The company, HeatTransfer, for which your analyzed data in Lab 5 is developing 8 new formulations to use for their widgets. To ensure that the formulations produce similar results when they are prepared by 6 plants in different locations, the company has asked each of the six plants to prepare each formulation and measure the thermal conductivity of the different formulations. You have been asked to develop a program to help analyze the data. Your program should have a main function and 3 other functions as described below. One function should confirm that the entered value for thermal conductivity is between 3 and 10 inclusive. This function should accept the thermal conductivity to be checked and the plant number that measured this thermal conductivity and prompt the user to re-enter the thermal conductivity for that plant until a valid value is entered. This function should return a valid value to the function call. One function should accept all 6 thermal conductivities (one for each of the plants) for a specific formulation at one time and send back to function call the highest and lowest of the 6 thermal conductivities to the function call. One function should accept all the thermal conductivities of a specific formulation and calculate the average of the thermal conductivities for that formulation without the highest and lowest thermal conductivity. This function should call the function to determine the lowest and highest thermal conductivity for a plant, then calculate the average. The average should be returned to the function call. The main function should prompt the user to enter the thermal conductivity for a formulation from each plant one at a time and call the function to ensure the entered value was valid . Next main should call the function to calculate the average of the values from the plants. This process should be repeated for each of the 8 formulations. The main function should output the average for each formulation to two decimal places. Sample output is given below for first 2 formulations (your code should work for all 8). Do not use any concepts beyond Chapter 6 (e.g. do not use arrays) to complete this project. Make sure that you have included your introductory comments containing the purpose of the program i.e. what problem or task is being solved plus the input needed from user to complete the problem/task, output expected from the program, and the processing needed to get the output from the input. The description of the purpose should be detailed enough Programming Project 2 2 CMPSC 201 – Fall 2016 that a person reading your code would not need any additional information to understand the problem. The processing comments should not include any C++ commands.

Enter the information for formulation 1.

Enter the thermal conductivity for formulation 1 from plant 1 in W/mK 7

Enter the thermal conductivity for formulation 1 from plant 2 in W/mK 3.8

Enter the thermal conductivity for formulation 1 from plant 3 in W/mK 9.9

Enter the thermal conductivity for formulation 1 from plant 4 in W/mK 5.3

Enter the thermal conductivity for formulation 1 from plant 5 in W/mK 8.7

Enter the thermal conductivity for formulation 1 from plant 6 in W/mK 9.5

The average thermal conductivity for formulation 1 was 7.63 W/mK.

Enter the information for formulation 2.

Enter the thermal conductivity for formulation 2 from plant 1 in W/mK 2.5

The thermal conductivity should be between 3 and 10 W/mK inclusive!

Enter the thermal conductivity from plant 1 3.8

Enter the thermal conductivity for formulation 2 from plant 2 in W/mK 8

Enter the thermal conductivity for formulation 2 from plant 3 in W/mK 11

The thermal conductivity should be between 3 and 10 W/mK inclusive!

Enter the thermal conductivity from plant 3 10.5

The thermal conductivity should be between 3 and 10 W/mK inclusive!

Enter the thermal conductivity from plant 3 9.2

Enter the thermal conductivity for formulation 2 from plant 4 in W/mK 5.3

Enter the thermal conductivity for formulation 2 from plant 5 in W/mK 6.8

Enter the thermal conductivity for formulation 2 from plant 6 in W/mK 7.9

The average thermal conductivity for formulation 2 was 7.00 W/mK.

Explanation / Answer

/* C++ program to calculate the average of the 8 formulation obtained from 6 plants.

*

*/

#include <iostream>

# include<math.h>

using namespace std;

float isValidConductivity(float con, int plantNumber);

void findMaxAndMinConductivity(float con1, float con2, float con3,float con4, float con5, float con6, float &max,float &min);

float averageConductivity(float con1,float con2,float con3,float con4,float con5,float con6);

int main() {

              

               float con1,con2,con3,con4,con5,con6,avg; // variables to store the thermal conductivity from 6 plants for each formulation and average

               // loop to continue that will take the inputs for conductivity values from 6 plants

               for(int i=0;i<8;i++)

               {

                              cout<<" Enter the information for formulation : "<<(i+1)<<endl;

                              cout<<" Enter the thermal conductivity for formulation "<<(i+1)<<" from plant 1 in W/mk: ";

                              cin>>con1;

                              con1 = isValidConductivity(con1,1);

                              cout<<" Enter the thermal conductivity for formulation "<<(i+1)<<" from plant 2 in W/mk: ";

                              cin>>con2;

                              con2 = isValidConductivity(con2,2);

                              cout<<" Enter the thermal conductivity for formulation "<<(i+1)<<" from plant 3 in W/mk: ";

                              cin>>con3;

                              con3 = isValidConductivity(con3,3);

                              cout<<" Enter the thermal conductivity for formulation "<<(i+1)<<" from plant 4 in W/mk: ";

                              cin>>con4;

                              con4 = isValidConductivity(con4,4);

                              cout<<" Enter the thermal conductivity for formulation "<<(i+1)<<" from plant 5 in W/mk: ";

                              cin>>con5;

                              con5 = isValidConductivity(con5,5);

                              cout<<" Enter the thermal conductivity for formulation "<<(i+1)<<" from plant 6 in W/mk: ";

                              cin>>con6;

                              con6 = isValidConductivity(con6,6);

                              avg = averageConductivity(con1,con2,con3,con4,con5,con6);

                              cout<<" The average thermal conductivity for formulation "<<i+1<<" was "<<avg<<" W.mk";

               }

               return 0;

}

/* function that checks if the conductivity value is valid i.e between 3 and 10 (inclusive), if not valid it prompts the user until the user provides a valid value

               Input is the conductivity value and the plant number that provided the value

               Output is the valid conductivity value for the plant

*/

float isValidConductivity(float con, int plantNumber)

{

               while(con<3 || con >10)

               {

                              cout<<"The thermal conductivity should be between 3 and 10 W/mk inclusive !";

                              cout<<" Enter the thermal conductivity from plant "<<plantNumber<<" in W/mk: ";

                              cin>>con;

               }

               return con;

}

/*

* function that computes the maximum and minimum conductivity value among the 6 values obtained from each plant.

* Inputs are the 6 conductivity values from each plant and varable max and min which will return the maximum and minimum value among the 6

* max and min are called by reference so changes in the variable will be reflected in the called function

*/

void findMaxAndMinConductivity(float con1, float con2, float con3,float con4, float con5, float con6, float &max,float &min)

{

               min = con1;

               max = con1;

               if(min > con2)

                              min = con2;

               if(min > con3)

                              min = con3;

               if(min > con4)

                              min = con4;

               if(min > con5)

                              min = con5;

               if(min > con6)

                              min = con6;

               if(max < con2)

                              max = con2;

               if(max < con3)

                              max = con3;

               if(max < con4)

                              max = con4;

               if(max < con5)

                              max = con5;

               if(max < con6)

                              max = con6;

}

/*

* function to calculate the average of the 6 conductivity values . The average computation doesn't include the max and min values.

* Inputs are the 6 conductivity values from each plat

* Output is the average

*/

float averageConductivity(float con1,float con2,float con3,float con4,float con5,float con6){

               float min,max;

               float avg;

               findMaxAndMinConductivity(con1,con2,con3,con4,con5,con6,max,min);

               avg = con1+con2+con3+con4+con5+con6 - max-min;

               avg = avg/4;

               //(discount*100)/100

               return roundf(avg*100)/100;

}

//End of program

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote