Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS123 – Quiz 4 Spring, 2013 Quiz Hints. Quiz 4 Hints Question 1 – Working with list elements  Create as a table 1st and convert to a list at the end.

Similar presentations


Presentation on theme: "CS123 – Quiz 4 Spring, 2013 Quiz Hints. Quiz 4 Hints Question 1 – Working with list elements  Create as a table 1st and convert to a list at the end."— Presentation transcript:

1 CS123 – Quiz 4 Spring, 2013 Quiz Hints

2 Quiz 4 Hints Question 1 – Working with list elements  Create as a table 1st and convert to a list at the end  Loop to assign all 0 elements  Change a single element following the loop  To develop the proc in question C. Pass in a list (eg. List1) Copy it to a new list (eg. NewList:=List1) Make the single value change in the newList Return the newList

3 Quiz 4 Hints Question 2 – Least Square and Spline curve fit comparisons – Remember to use with(CurveFitting) to bring in both curve fit packages – For the Spline fit, be sure to use the degree specified in your specific quiz problem – Use the eval function to evaluate each curve fit at a specific value – Use int to find the area under each curve

4 Quiz 4 Hints Question 3 – boolean temperatures – In your proc, return either true of false – Test proc at a number of temperatures below, at, within and above the lower and upper range values – Your proc should only take in a single temperature and return a single value of true or false

5 Quiz 4 Hints Question 3 – boolean temperatures – Your proc should merely take in a single temperature and return a single value of true or false – The looping over the temperature list in Part 2 should take place after the proc, and should call the proc for each input temperature – To access a temperature within the loop: Tlist[i], where Tlist is the list of input temperatures Store true/false proc results in a table while inside the loop and convert to a table afterward As you proceed through the loop, save each result to a 2nd table (for use in Part 3), since the table conversion will eliminate the original table

6 Quiz 4 Hints Question 3 – boolean temperatures – Part 3 Using the 2nd results table created in the processing loop in part 2, loop over each result and enter the associated temperature for each true result into a new table: Eg. – Tlist := [60, 70, 80] and – TFResults := [false, true, false] – ==> Part3Table := [70]

7 Quiz 4 Hints Question 4 – mortgage interest calculations – Your time step simulation algorithm should look some thing like this: Declare a table (eg. AmtOwed) to save each monthly owed amount Make sure your interest rate is in decimals, not % – 7% ==> 0.07 Initialize AmtOwed[1] to the original amount Use a “while” loop to continue looping as long as the amount owed (AmtOwed[i]) is >= the monthly payment amount – Within the loop, follow the calculation steps defined in the problem » Note – as soon as the interest owed for the loop period has been calculated, immediately round it to the nearest penny » Add the new amount owed into table element AmtOwed[i+1] before incrementing the counter i At the end of the while loop – Your loop counter should equal the total number of payments – AmtOwed[i+1] should be set to 0 before converting the table of monthly amounts owed to a list

8 Quiz 4 Hints Question 5 – Rectangle Integration – Part 1 Loop over the (number of rectangles -1) Accumulate the area = previous area + width*functionvalue(Lower+i*width) – Part 2 1st define the proc C representing the function Area := Area + width*C(Lower+i*width)


Download ppt "CS123 – Quiz 4 Spring, 2013 Quiz Hints. Quiz 4 Hints Question 1 – Working with list elements  Create as a table 1st and convert to a list at the end."

Similar presentations


Ads by Google