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

Data, Algorithms, Bounds Objective The objective is to explore the use of data a

ID: 2267985 • Letter: D

Question







Data, Algorithms, Bounds

Objective The objective is to explore the use of data and the development of temperature conversion and linear interpolation algorithms for calculating psi from a given temperature. Introduction Your program will calculate the resultant saturated pressure of our mythical vessel of special fluid and air to a global variable “vesselPressPsi”, from a temperature (degrees Fahrenheit, global variable vesselTempFahr). This temperature represents an electrical sensor input that was converted to engineering units. The linear interpolation algorithm is based on degrees Celsius. Requirements Design, Code, Test a C program which will loop forever calculating the resultant saturated pressure of our mythical vessel of special fluid and air to a global variable; vesselPressPsi, from a temperature (degrees Fahrenheit, global variable vesselTempFahr). Temperature will be provided by using a random number generator. Use the modulus operator to place your random number closer to the range dFahr (122-176F). This temperature represents an electrical sensor input that was converted to engineering units. The linear interpolation algorithm and corresponding data tables are based on degrees Celsius (local variable vesselTempCelsius). The program will have two pairs of data points See Appendix A, which provide corresponding pressure for a given Celsius temperature. One data pair is the upper and lower degree Celsius and the other pair is the upper and lower relative saturated pressure for the corresponding temperature. Compute the saturated pressure from the temperature input.
Since temperature in this assignment represents an electrical sensor input, we need to understand some basic constraints with sensors. Sometimes sensors are saturated or at their limits of operations, the sensor may respond (signal) with unknown values outside its working range. This could cause erratic or catastrophic conditions for control systems. This is solved by placing limiter testing at saturation points of sensors. Saturation testing imposes upper and lower bounds on a signal. When the input signal is within the range specified by lower limit and upper limit parameters, the input signal passes through unchanged. When the input signal is outside these bounds, the signal is clipped to the upper or lower bound values. Algorithm Not every Temperature input will have a direct corresponding pressure. For example if vesselTempCelsius = 65, which is neither of the known Celsius limits in Appendix A. Linear interpolation is a way to fill in the “holes'' in tables. Linear Interpolation is a method of constructing new data points within the range of a discrete set of known data points. Linear interpolation is quick and easy, but at times not very precise, to increase precision is to increase the number of data points with in the know set of data points.
In this assignment, you only have two data points, which represent the upper and lower data range.
Interpolation example with Appendix A: dFahr = 147.0

  
Result of hand test is psi= 0.2978 psi

Design considerations: 1. Notice, it was unclear or obvious that temp F needed to be converted to C? a. You may use #define symbolic constants or b. You may use 3define macros for in-line code c. Or a static algorithm to convert c2f 2. Use the debugger to set a known value of Fahrenheit. a. Do a manual range test, upper/lower, and equivalency-ish b. Make sure you have good random numbers, you may have to scale them 3. The code must perform Saturation testing. Provide your test plan for verifying Saturation testing in your header comment. 4. The data used to validate your hand calculations become your “known” data inputs to your code. That is a step in validating your code algorithm. Deliverables 40pts 1. <Hw5a> Fill out the Simple Requirements tractability form. a. This is an engineering process of design and test (V&V) b. To identify <all> requirements, a conceptual design and how to verify/validate the design meets the requirement c. Submit as Hw5a document (PDF, Word, or Excel compatibility) 2. <Hw5b> You are to follow the Programming Standards for this class. Appendix A

Temperature - t - (oc) Pressure - pv - (psia, lb/in2) 60 0.2563 70 0.3631





Data, Algorithms, Bounds

Objective The objective is to explore the use of data and the development of temperature conversion and linear interpolation algorithms for calculating psi from a given temperature. Introduction Your program will calculate the resultant saturated pressure of our mythical vessel of special fluid and air to a global variable “vesselPressPsi”, from a temperature (degrees Fahrenheit, global variable vesselTempFahr). This temperature represents an electrical sensor input that was converted to engineering units. The linear interpolation algorithm is based on degrees Celsius. Requirements Design, Code, Test a C program which will loop forever calculating the resultant saturated pressure of our mythical vessel of special fluid and air to a global variable; vesselPressPsi, from a temperature (degrees Fahrenheit, global variable vesselTempFahr). Temperature will be provided by using a random number generator. Use the modulus operator to place your random number closer to the range dFahr (122-176F). This temperature represents an electrical sensor input that was converted to engineering units. The linear interpolation algorithm and corresponding data tables are based on degrees Celsius (local variable vesselTempCelsius). The program will have two pairs of data points See Appendix A, which provide corresponding pressure for a given Celsius temperature. One data pair is the upper and lower degree Celsius and the other pair is the upper and lower relative saturated pressure for the corresponding temperature. Compute the saturated pressure from the temperature input.
Since temperature in this assignment represents an electrical sensor input, we need to understand some basic constraints with sensors. Sometimes sensors are saturated or at their limits of operations, the sensor may respond (signal) with unknown values outside its working range. This could cause erratic or catastrophic conditions for control systems. This is solved by placing limiter testing at saturation points of sensors. Saturation testing imposes upper and lower bounds on a signal. When the input signal is within the range specified by lower limit and upper limit parameters, the input signal passes through unchanged. When the input signal is outside these bounds, the signal is clipped to the upper or lower bound values. Algorithm Not every Temperature input will have a direct corresponding pressure. For example if vesselTempCelsius = 65, which is neither of the known Celsius limits in Appendix A. Linear interpolation is a way to fill in the “holes'' in tables. Linear Interpolation is a method of constructing new data points within the range of a discrete set of known data points. Linear interpolation is quick and easy, but at times not very precise, to increase precision is to increase the number of data points with in the know set of data points.
In this assignment, you only have two data points, which represent the upper and lower data range.
Interpolation example with Appendix A: dFahr = 147.0

  
Result of hand test is psi= 0.2978 psi

Design considerations: 1. Notice, it was unclear or obvious that temp F needed to be converted to C? a. You may use #define symbolic constants or b. You may use 3define macros for in-line code c. Or a static algorithm to convert c2f 2. Use the debugger to set a known value of Fahrenheit. a. Do a manual range test, upper/lower, and equivalency-ish b. Make sure you have good random numbers, you may have to scale them 3. The code must perform Saturation testing. Provide your test plan for verifying Saturation testing in your header comment. 4. The data used to validate your hand calculations become your “known” data inputs to your code. That is a step in validating your code algorithm. Deliverables 40pts 1. <Hw5a> Fill out the Simple Requirements tractability form. a. This is an engineering process of design and test (V&V) b. To identify <all> requirements, a conceptual design and how to verify/validate the design meets the requirement c. Submit as Hw5a document (PDF, Word, or Excel compatibility) 2. <Hw5b> You are to follow the Programming Standards for this class. Appendix A

Temperature - t - (oc) Pressure - pv - (psia, lb/in2) 60 0.2563 70 0.3631





Data, Algorithms, Bounds

Objective The objective is to explore the use of data and the development of temperature conversion and linear interpolation algorithms for calculating psi from a given temperature. Introduction Your program will calculate the resultant saturated pressure of our mythical vessel of special fluid and air to a global variable “vesselPressPsi”, from a temperature (degrees Fahrenheit, global variable vesselTempFahr). This temperature represents an electrical sensor input that was converted to engineering units. The linear interpolation algorithm is based on degrees Celsius. Requirements Design, Code, Test a C program which will loop forever calculating the resultant saturated pressure of our mythical vessel of special fluid and air to a global variable; vesselPressPsi, from a temperature (degrees Fahrenheit, global variable vesselTempFahr). Temperature will be provided by using a random number generator. Use the modulus operator to place your random number closer to the range dFahr (122-176F). This temperature represents an electrical sensor input that was converted to engineering units. The linear interpolation algorithm and corresponding data tables are based on degrees Celsius (local variable vesselTempCelsius). The program will have two pairs of data points See Appendix A, which provide corresponding pressure for a given Celsius temperature. One data pair is the upper and lower degree Celsius and the other pair is the upper and lower relative saturated pressure for the corresponding temperature. Compute the saturated pressure from the temperature input.
Since temperature in this assignment represents an electrical sensor input, we need to understand some basic constraints with sensors. Sometimes sensors are saturated or at their limits of operations, the sensor may respond (signal) with unknown values outside its working range. This could cause erratic or catastrophic conditions for control systems. This is solved by placing limiter testing at saturation points of sensors. Saturation testing imposes upper and lower bounds on a signal. When the input signal is within the range specified by lower limit and upper limit parameters, the input signal passes through unchanged. When the input signal is outside these bounds, the signal is clipped to the upper or lower bound values. Algorithm Not every Temperature input will have a direct corresponding pressure. For example if vesselTempCelsius = 65, which is neither of the known Celsius limits in Appendix A. Linear interpolation is a way to fill in the “holes'' in tables. Linear Interpolation is a method of constructing new data points within the range of a discrete set of known data points. Linear interpolation is quick and easy, but at times not very precise, to increase precision is to increase the number of data points with in the know set of data points.
In this assignment, you only have two data points, which represent the upper and lower data range.
Interpolation example with Appendix A: dFahr = 147.0

  
Result of hand test is psi= 0.2978 psi

Design considerations: 1. Notice, it was unclear or obvious that temp F needed to be converted to C? a. You may use #define symbolic constants or b. You may use 3define macros for in-line code c. Or a static algorithm to convert c2f 2. Use the debugger to set a known value of Fahrenheit. a. Do a manual range test, upper/lower, and equivalency-ish b. Make sure you have good random numbers, you may have to scale them 3. The code must perform Saturation testing. Provide your test plan for verifying Saturation testing in your header comment. 4. The data used to validate your hand calculations become your “known” data inputs to your code. That is a step in validating your code algorithm. Deliverables 40pts 1. <Hw5a> Fill out the Simple Requirements tractability form. a. This is an engineering process of design and test (V&V) b. To identify <all> requirements, a conceptual design and how to verify/validate the design meets the requirement c. Submit as Hw5a document (PDF, Word, or Excel compatibility) 2. <Hw5b> You are to follow the Programming Standards for this class. Appendix A

Temperature - t - (oc) Pressure - pv - (psia, lb/in2) 60 0.2563 70 0.3631





Data, Algorithms, Bounds

Objective The objective is to explore the use of data and the development of temperature conversion and linear interpolation algorithms for calculating psi from a given temperature. Introduction Your program will calculate the resultant saturated pressure of our mythical vessel of special fluid and air to a global variable “vesselPressPsi”, from a temperature (degrees Fahrenheit, global variable vesselTempFahr). This temperature represents an electrical sensor input that was converted to engineering units. The linear interpolation algorithm is based on degrees Celsius. Requirements Design, Code, Test a C program which will loop forever calculating the resultant saturated pressure of our mythical vessel of special fluid and air to a global variable; vesselPressPsi, from a temperature (degrees Fahrenheit, global variable vesselTempFahr). Temperature will be provided by using a random number generator. Use the modulus operator to place your random number closer to the range dFahr (122-176F). This temperature represents an electrical sensor input that was converted to engineering units. The linear interpolation algorithm and corresponding data tables are based on degrees Celsius (local variable vesselTempCelsius). The program will have two pairs of data points See Appendix A, which provide corresponding pressure for a given Celsius temperature. One data pair is the upper and lower degree Celsius and the other pair is the upper and lower relative saturated pressure for the corresponding temperature. Compute the saturated pressure from the temperature input.
Since temperature in this assignment represents an electrical sensor input, we need to understand some basic constraints with sensors. Sometimes sensors are saturated or at their limits of operations, the sensor may respond (signal) with unknown values outside its working range. This could cause erratic or catastrophic conditions for control systems. This is solved by placing limiter testing at saturation points of sensors. Saturation testing imposes upper and lower bounds on a signal. When the input signal is within the range specified by lower limit and upper limit parameters, the input signal passes through unchanged. When the input signal is outside these bounds, the signal is clipped to the upper or lower bound values. Algorithm Not every Temperature input will have a direct corresponding pressure. For example if vesselTempCelsius = 65, which is neither of the known Celsius limits in Appendix A. Linear interpolation is a way to fill in the “holes'' in tables. Linear Interpolation is a method of constructing new data points within the range of a discrete set of known data points. Linear interpolation is quick and easy, but at times not very precise, to increase precision is to increase the number of data points with in the know set of data points.
In this assignment, you only have two data points, which represent the upper and lower data range.
Interpolation example with Appendix A: dFahr = 147.0

  
Result of hand test is psi= 0.2978 psi

Design considerations: 1. Notice, it was unclear or obvious that temp F needed to be converted to C? a. You may use #define symbolic constants or b. You may use 3define macros for in-line code c. Or a static algorithm to convert c2f 2. Use the debugger to set a known value of Fahrenheit. a. Do a manual range test, upper/lower, and equivalency-ish b. Make sure you have good random numbers, you may have to scale them 3. The code must perform Saturation testing. Provide your test plan for verifying Saturation testing in your header comment. 4. The data used to validate your hand calculations become your “known” data inputs to your code. That is a step in validating your code algorithm. Deliverables 40pts 1. <Hw5a> Fill out the Simple Requirements tractability form. a. This is an engineering process of design and test (V&V) b. To identify <all> requirements, a conceptual design and how to verify/validate the design meets the requirement c. Submit as Hw5a document (PDF, Word, or Excel compatibility) 2. <Hw5b> You are to follow the Programming Standards for this class. Appendix A

Temperature - t - (oc) Pressure - pv - (psia, lb/in2) 60 0.2563 70 0.3631

Explanation / Answer

#include<iostream>
#include<iomanip>
using namespace std;
double FtoC(double);
double CtoF(double);
void displayMenu();
char getMenuSelection();
void getStartEndAndIncrement(double&,double&,double& );
void displayTable(char,double,double,double);
int main()
{
char choice;
double start_temp, end_temp, temp_incr;
choice=getMenuSelection ( );
do
{getStartEndAndIncrement( start_temp, end_temp, temp_incr) ;
displayTable(choice,start_temp, end_temp, temp_incr);
getchar();
cout<<"press enter to continue ";
do
   {choice=getchar();
    }while(choice!=' ');
choice=getMenuSelection ( );     
}while(choice!='Q');
return 0;
}

void displayTable(char choice,double start_temp,double end_temp,double temp_incr)
{if(choice=='F')
     {cout <<" "<<(char)248<<"F "<<(char)248<<"C"<<endl;
      cout<< "    ------   -------"<<endl;
      while(start_temp<=end_temp)
           {cout<<setw(10)<<setprecision(1)<<fixed<<start_temp<<
           setw(10)<<setprecision(1)<<fixed<<FtoC(start_temp)<<endl;
            start_temp+=temp_incr;
           }
      }
else if(choice=='C')
      {cout <<"   "<< (char)248<<"C "<<(char)248<<"F"<<endl;
       cout << " -----      -------"<<endl;
       while(start_temp<=end_temp)
           {cout<<setw(7)<<setprecision(1)<<fixed<<start_temp<<
           setw(13)<<setprecision(1)<<fixed<<CtoF(start_temp)<<endl;
            start_temp+=temp_incr;
           }
      }
cout<<endl;
}


void getStartEndAndIncrement(double& start_temp,double& end_temp,double& temp_incr)
{cout<<"Enter starting temperature: ";
cin>>start_temp;
cout<<"Enter ending temperature: ";
cin>>end_temp;
cout<<"Enter temperature increment: ";
cin>>temp_incr;
}     

double FtoC(double t)
{return 5./9.*(t-32.);
       }
double CtoF(double t)
{return 9./5.*t+32.;
       }
void displayMenu()
{cout<<"Menu ";
cout<<"F. Convert F to C "<<endl;
cout<<"C. Convert C to F "<<endl;
cout<<"Q. Quit "<<endl;
cout<<"What is your choice? " <<endl;
}
char getMenuSelection ( )
{char choice;
do
{displayMenu();
cin>>choice;
choice=toupper(choice);
switch(choice)
   {default: cout<<"invalid entry ";
             break;
    case 'C': case 'F': case 'Q': break;
    }    
}while(choice!='C'&&choice!='F'&&choice!='Q');
return choice;
}