%**********************************************************
%             |  Author: James C. Sutherland  |
%             |-------------------------------|
%
% This code produces a table of temperatures in F, R, C and K.
% The user enters the starting and ending temperatures (in F)
% as well as the number of points in the table.  The table is
% written to disk as a file called "tempTable.dat"
%
%**********************************************************

clear; clc;

Tlo = input('Enter the starting temperature (F): ');
Thi = input('Enter the ending temperature (F): ');
n   = input('Enter the number of points in the table: ');

TF = linspace(Tlo,Thi,n)';

TR = 459.67 + TF;
TC = (TF-32) * 5/9;
TK = TC + 273.15;

tfile = fopen('tempTable.dat','w');

fprintf(tfile,'\n\nFahrenheit  Rankine  Celsius  Kelvin\n');
fprintf(tfile,'--------------------------------------\n');

for i=1:n
  fprintf(tfile,'%10.2f   %7.2f  %7.2f %7.2f\n', TF(i), TR(i), TC(i),TK(i));
end

fclose(tfile);