- #1
- 18
- 0
Homework Statement
Write a program that does the following:
- Prints the four gases on the screen and asks the user to select which gas to find the heat capacity for.
- Asks the user for a temperature.
- Asks the user if another temperature is needed (enter yes or no). If the answer is yes, the user is asked to enter another temperature. This process continues until the user enters no.
- Display a table containing the temperatures entered and the corresponding heat capacities.
The table containing the gases and the values for a, b, c and d is attached.
Homework Equations
Heat Capacity = Cp
Cp = a + bT + cT^2 + dT^3
The Attempt at a Solution
display('-----------------------------------------------------------------')
clear
display('Problem 32')
SO2.a = 38.91; SO2.b = 3.904*10^-2; SO2.c = -3.105*10^-5; SO2.d = 8.606*10^-9;
SO3.a = 48.50; SO3.b = 9.188*10^-2; SO3.c = -8.540*10^-5; SO3.d = 32.40*10^-9;
O2.a = 29.10; O2.b = 1.158*10^-2; O2.c = -0.6076*10^-5; O2.d = 1.311*10^-9;
N2.a = 29.00; N2.b = 0.2199*10^-2; N2.c = -0.5723*10^-5; N2.d = -2.871*10^-9;
inputval = input('Select a gas, SO2, SO3, O2, or N2: ');
T = input('Input a temperature, in celsius,: ');
Cp1 = inputval.a + inputval.b*T + inputval.c*(T)^2 + inputval.d*(T)^3;
Table = [T Cp1]
reply = input('Do you want to input another temperature? Y/N: ','s');
Cp2 = 0;
Table1 = [];
while reply == 'Y'
T1 = input('Input another temperature: ');
Cp2 = inputval.a + inputval.b*T1 + inputval.c*(T1)^2 + inputval.d*(T1)^3;
Table1 = [T1 Cp2];
Table1 = [Table1 ; Table1];
reply = input('Do you want to input another temperature? Y/N: ','s');
end
answer = [Table; Table1]
disp(answer)
I'm not sure where my error is, could someone help?