BFOIT - Introduction to Computer Programming
Background
jLogo Programming
- Commanding a Turtle
- Pseudocode
- Adding New Commands
- Iteration & Animation
- Hierarchical Structure
- Procedure Inputs
- Operators & Expressions
- Defining Operators
- Words & Sentences
- User Interface Events
- What If? (Predicates)
- Recursion
- Local Variables
- Global Variables
- Word/Sentence Iteration
- Mastermind Project
- Turtles As Actors
- Arrays
- File Input/Output
Java
- A Java Program
- What's a Class?
- Extending Existing Classes
- Types
- Turtle Graphics
- Control Flow
- User Interface Events
Appendices
- Jargon
- TG Directives
- jLogo Primitives
- TG Editor
- Java Tables
- Example Programs
- *** New ***:
Installation Notes
Updates
- December 13, 2008
- January 6, 2012
- March 15, 2013
- January 20, 2014
- February 13, 2014
- July 29, 2014
- January 18, 2016
- January 29, 2016
- August 19, 2016
Lastly
Practice Answers: Expressions and Plumbing Diagrams
-
Draw a plumbing diagram for a tip calculator which takes two
numbers as inputs: the bill's total cost and the percentage of the
tip. The output of the expression (the amount of the tip) should
be input to a println command box.
to tipCalc :total :tipPercent println quotient (product :total :tipPercent) 100 end
Bill Total Tip % Tip $ $10 15 1.50 $15 20 3.00 $32 16 5.12 $22 18 3.96 $47 17 7.99 -
The average of a bunch of numbers is the sum of the numbers divided by
the number of numbers.
Draw a plumbing diagram for the expression which averages four numbers.(a) 66, 10, 47 (Average: 41) (b) 22, 87, 15, 41 (Average: 42) (c) 83, 31, 72, 19, 6 (Average: 43)
to avg3num :num1 :num2 :num3 println quotient (sum (sum :num1 :num2) :num3) 3 end to avg4num :num1 :num2 :num3 :num4 println quotient (sum (sum (sum :num1 :num2) :num3) :num4) 4 end to avg5num :num1 :num2 :num3 :num4 :num5 println quotient (sum (sum (sum (sum :num1 :num2) :num3) :num4) :num5) 5 end
-
Given Pythagoras'
Theorem (the length of the hypotenuse of a right triangle is equal
to the square root of the sum of the squares of each of its legs' lengths),
Then write a procedure which prints the length of the hypotenuse of a right triangle, given the lengths of its legs.to hypotenuseLength :leg1Len :leg2Len println sqrt sum (product :leg1Len :leg1Len) (power :leg2Len 2) end
-
Write procedures which display the surface area and the volume of
a sphere, given its radius. Here are the formulas you need.
Fill in the empty cells with the values your procedures print rounded to thousandths.to sphereSurfaceArea :radius println product 4 (product 3.14159 (product :radius :radius)) end or to sphereSurfaceArea :radius println product 4 (product 3.14159 (power :radius 2)) end and to sphereVolume :radius println product (quotient 4 3) (product 3.14159 (product :radius (product :radius :radius))) end or to sphereVolume :radius println product (quotient 4 3) (product 3.14159 (power :radius 3)) end
Unit
AmountSurface Area
(Unit2)Volume
(Unit3)1 12.566 4.189 2 50.265 33.510 3 113.097 113.097 4 201.062 268.083