The Heat is on

Heat is consumed in raising the temperature of water and also in converting it from ice to liquid and from liquid to vapor. To raise the temperature of ice requires .48 calories for each gram of ice and each degree Celsius of change. To change ice at 0 degree C to liquid at 0 requires 79.8 calories per gram. To raise the temperature of liquid water by  requires 1 calorie per gram per degree. To change liquid to vapor (both at 100 C) requires 540 calories per gram. Finally to raise the temperature of one gram of water vapor by one degree requires .475 calories. We will write a program to determine the heat required to raise the temperature of water from t1 to t2.
As an example, if 20 grams of water is to be heated from -30 C to 110 C the following calculation gives the heat needed:  30*20*.48 (raise the temp of ice) +  20 *79.8 (ice to liquid) + 100*20*1 (raise temp from 0 to 100) +20*540(liquid to vapor) + 10*20*.475 (raise temp of vapor).
We will assume that the user is asked to input the lower temperature (t1) followed by the higher one (t2) as well as the grams of water.
Until further notice we will also assume that neither t1 nor t2 is 0 or 100.
A.
1. Assume t2 < 100 and fill in the blanks     
 if (t1 < 0)         
    if (t2 < 0)             
         heat  = g*______ * _________          
     else             heat = g* t1*.48 + g*_________ +g*______ * _________
Put this into a small program and test it with the following data
t1 = -20, g = 5, t2 =40 then heat = 647
t1 = -50, g = 5, t2 = -10 heat = 96

2. We now drop the assumption that t2 <100.
Fill in the new blanks and supply appropriate "end"'s.
 if (t1 < 0)        
     if (t2 < 0)             
         heat  = g*______ * _________         
      elseif t2 <100             
         heat = g*t1 *.48  + g*_____+ g*_____* _________                 
      else  
                    heat = g*t1*.48 + g*____ +g*100 +g*______ +g*______*.475

Draw the flow chart for this and write a small program to test it. Turn in the flow chart

3. If  0 < t1 < 100, what two cases for t2 must be considered? Write a small program to calculate the heat needed for either case.

4. If t1>100 what is the equation for heat?

5. Now write a program putting your results from 2, 3, and 4. Turn this in as an .m file.  Also turn in the flow chart.

6. Here is an alternative way to write the program. Note that that one always has: heat = g*.48*c1 + g*79.8 * c2 + g*c3 + g*540 * c4 + g *.475 *c5 where c1,c2, ..c5 depend on the positions of t1 and t2 relative to 0 and 100.  For example if t1<0 and t2 < 0, then c1 = t2 - t1 and c2=c3=c4=c5 =0. If t1>0 and t1<100 and t2 >100 then c1 =0, c2 = 0, c3 =100-t1, c4 =1, c5 =t2-100.    
Fill in the blanks for the following:    if ( (t1< 0) & (t2 >100) )      c1= __ ;  c2 = __ ;  c3 = ___ ; c4 = ____;  c5 = _____ ;  end  
 if  ( ________________________)      c1 = 0; c2 = 0; c3 = 0; c4 = 0; c5 = t2 - t1;  end    
B: Write a program  for all different possible combinations of t1,t2 which assigns c1,c2,c3,c4,c5 after an if or elseif or else and then has only one line that calculates the heat from the various assignments of the ci’s for the different cases in the ifs. Turn this in as an .m file