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.

Slides:



Advertisements
Similar presentations
Programming with App Inventor Computing Institute for K-12 Teachers Summer 2012 Workshop.
Advertisements

CATHERINE AND ANNIE Python: Part 3. Intro to Loops Do you remember in Alice when you could use a loop to make a character perform an action multiple times?
CS 101 Introductory Programming - Lecture 7: Loops In C & Good Coding Practices Presenter: Ankur Chattopadhyay.
Solving Problems with Repetition. Objectives At the end of this topic, students should be able to: Correctly use a while statement in a C# program Correctly.
Flow Charts, Loop Structures
 Control structures  Algorithm & flowchart  If statements  While statements.
Mathematical. Approach  Many of these problems read as brain teasers at first, but can be worked through in a logical way.  Just remember to rely on.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Objectives In this chapter, you will learn about:
ITC 240: Web Application Programming
Chapter 4 - Control Structures: Part 1 Outline 4.4Control Structures 4.5The if Selection Structure 4.6The if/else Selection Structure 4.7The while Repetition.
Week 10 Recap CSE 115 Spring For-each loop When we have a collection and want to do something to all elements of that collection we use the for-each.
C Lecture Notes 1 Program Control (Cont...). C Lecture Notes 2 4.8The do / while Repetition Structure The do / while repetition structure –Similar to.
Computer Science 1620 Multi-Dimensional Arrays. we used arrays to store a set of data of the same type e.g. store the assignment grades for a particular.
More on Numerical Computation CS-2301 B-term More on Numerical Computation CS-2301, System Programming for Non-majors (Slides include materials from.
Computer Science 1620 Programming & Problem Solving.
More about Numerical Computation CS-2301, B-Term More about Numerical Computation CS-2301, System Programming for Non-Majors (Slides include materials.
C++ Operators CS242 COMPUTER PROGRAMMING T.Banan Al-Hadlaq.
A revision guide for programming with python. 1.A program is a set of instructions that tells a computer what to do. 2.The role of a programmer is to.
Programmable Logic Controllers
CS 101: Numerical Computing Abhiram Ranade. Representing Integers “int x;” : reserves one cell in memory for x. One cell: “One word” has 32 capacitors.
CH2 – Using Data. Constant Something which cannot be changed Data Type Format and size of a data item Intrinsic Data Types Pg. 47 – Table 2-1 Basic ones.
Control Structures Week Introduction -Representation of the theory and principles of structured programming. Demonstration of for, while,do…whil.
Lec 6 Data types. Variable: Its data object that is defined and named by the programmer explicitly in a program. Data Types: It’s a class of Dos together.
If statements while loop for loop
30/10/ Iteration Loops Do While (condition is true) … Loop.
An Introduction to Programming with C++ Sixth Edition Chapter 7 The Repetition Structure.
Loop.  While Loop  Do-while Loop  For Loop Continue Statement Conclusion Loop Loop.
Lecture 4: Calculating by Iterating. The while Repetition Statement Repetition structure Programmer specifies an action to be repeated while some condition.
Repetition Structures Repetition Structures allow you to write programs that will repeat program steps multiple times. –Also called Loops –Counter controlled.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 5 Looping.
+ Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy Walters, and Godfrey Muganda Chapter 5: Looping.
Control Structures - Selections - Repetitions/iterations (part 2) 1 -Based on slides from Deitel & Associates, Inc. - Revised by T. A. Yang.
Repetition. Loops Allows the same set of instructions to be used over and over again Starts with the keyword loop and ends with end loop. This will create.
2016 N5 Prelim Revision. HTML Absolute/Relative addressing in HTML.
CS 121 – Quiz Feb 17 th. Question 2 We want to count how many days there were such that the temperature is at least degrees lower than the.
1 Standard Version of Starting Out with C++, 4th Brief Edition Chapter 5 Looping.
A: A: double “4” A: “34” 4.
Hossain Shahriar Announcement and reminder! Tentative date for final exam shown below, please choose a time slot! December 19.
LECTURE # 8 : REPETITION STATEMENTS By Mr. Ali Edan.
Chapter 7: The Repetition Structure Introduction to Programming with C++ Fourth Edition.
CS0007: Introduction to Computer Programming The for Loop, Accumulator Variables, Seninel Values, and The Random Class.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
Solving Problems with Repetition Version 1.0. Objectives At the end of this topic, students should be able to: Correctly use a while statement in a C#
An Introduction to Programming with C++ Sixth Edition Chapter 5 The Selection Structure.
General Condition Loop A general condition loop just loops while some condition remains true. Note that the body of the loop should (eventually) change.
Introduction to programming in java Lecture 11 Boolean Expressions and Assignment no. 2.
CS 1023 Intro to Engineering Computing 3: Computer Programming Looping Statements Mark Kerstetter Department of Computer Science Western Michigan University.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
CSC111 Quick Revision.
while Repetition Structure
Tutorial 9 - Car Payment Calculator Application Introducing the while Repetition Statement Outline 9.1 Test-Driving the Car Payment Calculator Application.
Chapter 10 © 2011, The McGraw-Hill Companies, Inc.
The Selection Structure
CS 1430: Programming in C++.
Operators and Expressions
Review Operation Bingo
One-Dimensional Array Introduction Lesson xx
Conditions and Ifs BIS1523 – Lecture 8.
More about Numerical Computation
Java Programming Loops
CSI 101 Elements of Computing Spring 2009
Do While (condition is true) … Loop
Dr. Sampath Jayarathna Cal Poly Pomona
Java Programming Loops
Life is Full of Alternatives
Review of Previous Lesson
CS2011 Introduction to Programming I Loop Statements (I)
COMPUTING.
Presentation transcript:

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  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

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

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

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

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]

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

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)