View the step-by-step solution to:

# T(F) R1 R2 R3 R4 95.20 66.10 43.10 29.00 96.10 67.60 43.50 31.20 97.40 67.00 43.70 30.50 98.20 69.10 44.10 30.70 99.90 68.00 44.70 32.80 100.50 71.10...

Programming Assignment 3 Spring 2010

Calibration of a resistance temperature detector

Problem Statement:

This assignment will test your knowledge of: linear regression and using arrays with functions. This program will use material covered through Chapter 2 and Section 4..

A resistance temperature detector (RTD) is an economical device that measures temperature. It relies on the characteristic of certain materials to have a linear relationship between temperature and electrical resistance over a range of temperatures.

Your task is to evaluate several candidate metal alloys to determine which would be best suited for a household thermometer used to measure body temperature. Your test lab has given you a data file temperaturedata.txt (right click here to save the data file) which has resistance versus temperature for four metal alloys. Your job is to determine which metal alloy has the most linear relationship between temperature and resistance.

Program Specifics:

Write a C++ program that:

1. Reads the data file, temperaturedata.txt, exactly as it appears, into a two-dimensional array. Note: Failure to use a two dimensional array will cost up to a 10 point deduction. To skip over the heading text you will need to use the function getline discussed in Section 2.12.3.

2. Uses three separate single result double functions (do not use void functions) to determine the slope, intercept, and r-squared for each data set. Failure to use three double single result functions will cost up to a 10 point deduction.

3. Writes the results of the analysis and the input data to the screen using good format (i.e. use iomanip functions) for your output.

4. Prints to the screen the ID (R1, etc) of the metal alloy that demonstrates the most linear relationship (i.e. r-squared closest to 1.0).

5. In a while loop the program asks the user for a resistance and the program returns the temperature using the RTD alloy that has the best fit (the one that you found in part 4). The program ends when a zero is entered for the resistance.

Example C++ output is shown below. Note that the slopes and intercepts are determined with Temp as the dependent variable (y) and R's are the independent variables (x). This is a bit backwards, but it makes doing part 5 easier. A good suggestion is to complete the calculations in excel so you can debug your calculations in the C++ program.

output

T(F) R1 R2 R3 R4 95.0 95.20 66.10 43.10 29.00 96.0 96.10 67.60 43.50 31.20 97.0 97.40 67.00 43.70 30.50 98.0 97.20 69.10 44.10 30.70 99.0 98.90 68.00 44.70 32.80 100.0 99.50 71.10 45.10 31.50 101.0 101.00 71.20 45.30 31.60 102.0 101.60 71.00 45.70 30.50 103.0 101.80 73.10 46.30 32.50 104.0 103.70 73.50 46.60 32.70 105.0 105.60 72.80 47.10 33.60

### Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

### -

Educational Resources
• ### -

Study Documents

Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

Browse Documents