CMPUT 101 Lab #3 September 24, 2007 14:00 – 17:00.

Slides:



Advertisements
Similar presentations
Creating Tables The basics, nothing pretty, but it works.
Advertisements

Copyright, Joseph Bergin
Lab 10 : Arithmetic Systems : Adder System Layout: Slide #2 Slide #3 Slide #4 Slide #5 Arithmetic Overflow: 2’s Complement Conversions: 8 Bit Adder/Subtractor.
Multiplication Practice Do you know how to multiply with double digits?
Science Balancing Equations. WATER is made from OXYGEN and HYDROGEN Hydrogen + Oxygen Water.
MrV’s Shorthand Division (by Single Digits 2, 5, and 3) It Helps You Do Prime Factorization using Factor Trees: If you are SURE that a long number divides.
Evolutionary Learning. Some Examples of Biologically Inspired AI Neural networks Evolutionary computation (e.g., genetic algorithms) Immune-system-inspired.
CMPUT 101 Lab # 2 September 17, :00 – 16:50.
1 COMP541 Arithmetic Circuits Montek Singh Mar 20, 2007.
MAT 1000 Mathematics in Today's World Winter 2015.
Multiplying Multiple Digit Numbers
Addition Algorithms S. Matthews. Partial-Sums Method for Addition Add from left to right and column by column. The sum of each column is recorded on a.
Binary Addition CSC 103 September 17, 2007.
Use effective written methods to add whole numbers.
Physics: Chapter 3 Vector & Scalar Quantities
1 Ch. 7 Recursion similar to iteration in that you repeatedly do a little bit of the task and then “loop” again and work on a smaller piece - eventually.
Chapter 2- Decimals.
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
Karel the Robot A Gentle Introduction to the Art of Programming.
ADDING AND SUBTRACTING DECIMALS Lesson Lesson Objectives After completing this lesson, you will be able to say: I can add decimals I can subtract.
Add and Subtract Decimals
Thanks to Dr. Kris Schindler for this (and all Karel the Robot slides)
BR 8/99 Binary Numbers Again Recall than N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to 255.
Ways to Check for Divisibility Dividing By 1 All numbers are divisible by 1.
1 Arithmetic Logic Unit ALU. 2 The Bus Concept 3 CPU Building Blocks  Registers (IR, PC, ACC)  Control Unit (CU)  Arithmetic Logic Unit (ALU)
1 karel_part2_Inheritance Extending Robots Tired of writing turnRight every time you start a new karel project. How do we avoid re-writing code all the.
1 Karel – Chapter 6 Instructions That Repeat Note: Original slides provided by and modified for Mr. Smith’s AP Computer Science.
Vector Resolution Honors Physics.
$100 $200 $300 $400 $100 $200 $300 $400 $300 $200 $100 Adding doublesAdd 3 numbersAdd 1 to 2 digit numbers Ways to makes numbers Add & find missing.
15-100: Introduction to Programming w/ Java * Ananda Gunawardena -- Lecture – School of Computer Science – Phone : (x81559) – Office: Wean Hall.
Ways to Check for Divisibility Dividing By 1 All numbers are divisible by 1.
Assembly Language Friday, Week 5 Monday, Week 6. Assembly Language  Set of mnemonic names for the instructions in a particular computer's machine language.
Adding and subtracting decimal numbers Written methods.
Analog and Digital Signals Binary Code 7th Grade Science.
All even numbers are divisible by 2 Even numbers are numbers that end with either 0, 2, 4, 6, or 8.
Subtraction with borrowing. SUBTRACTION WITH BORROWING Start with the right-hand column as usual When you try to take the 7 away from the 3,
Confidential1 Multiplying Decimals. Confidential2 WARM UP – = = – = Is it true?
Ways to Check for Divisibility Dividing by 2 All even numbers are divisible by 2 Even numbers are numbers that end with either 2, 4, 6, 8, or 0.
Adding 2-digit numbers with regrouping. Always add the ones place first
$100 $200 $300 $400 $100 $200 $300 $400 $300 $200 $100 Adding multiples of 10 Add 1 to 2 digit numbers with regrouping Add 3 two digit numbers Ways.
What is a mixed number? A mixed number is made up of a whole number and a fraction (part of a whole). *Watch the video to learn more about adding mixed.
Adding Two and Three Digit Numbers
With Two-Digit Numbers. 1a. Multiply one’s column x 1 1 * 1 = 1.
Estimation and Computation By: Your Name (First, Last) Section: O-
Casne.ncl.ac.uk Taking care of the CrumbleBot Please do NOT stress the robot's motors 1.Do NOT push the robot 2.Do NOT hold the.
Module 4 Lesson 8. Objective:  Use math drawings to represent the composition and relate drawings to a written method.
By: Megan Funk. I will: 1. Explain the binary number system How to: -Generate binary from a number -Add binary 2. Explain the base-b number system 3.
Lecture 4: Digital Systems & Binary Numbers (4)
CS 106A, Lecture 3 Problem-solving with Karel
Rounding Tens and Hundreds
Vector Resolution Level 1 Physics.
Copyright © 2008 by Helene G. Kershner
Copyright © 2008 by Helene G. Kershner
Multiply By Two Digits Created by M. Guy.
CS 106A, Lecture 2 Programming with Karel
How to Multiply By Two Digits
5Th Class Maths Additon & Subtraction.
TAO1221 COMPUTER ARCHITECTURE AND ORGANIZATION LAB 6
Karel J Robot OOP approach to learning computer science
Fundamentals of Data Representation
Algorithm Discovery and Design
Karel J Robot OOP approach to learning computer science
Vector Resolution.
Pair work – Do you want to change seats??
Task Planner for Column Addition Step What to do How it should look
Multi-Digit Addition and Subtraction
Task Planner for Column Addition Step What to do How it should look
Theory: 2.6 – Data Representation
Jeroo Code 7-Sep-19.
Presentation transcript:

CMPUT 101 Lab #3 September 24, :00 – 17:00

Guido: Adding numbers Today work: A program that lets GvR add two 3-digit numbers using 10 based representation. Follow the step in the lab exercise 3

Step 1 Load worlds: lab_3_one_a.wld -- single digit without carry lab_3_one_b.wld – single digit with carry

Step 2 & 3 Load provided program: lab_3a.gvr Make sure the program works Copy/paste may cause spacing problem By executing it, the robot will be just turned off Add your code in the space provided

Step 4 Program a robot to add two single digit numbers. Consider to use move_south, move_north, move_east, move_west, and add_digit_to_bag provided in the initial program Define a new sub routine as: add_two_digits (Suggestion) Don’t worry about the carry yet – GvR just keeps all beepers in his bag. Test on the worlds in Step 1. Demo -- lab_3a_4.gvr

Step 5 Think about the carry Adding two numbers always give either 0 or 1 carry --- why ? Consider in the largest possible = 1998 the largest sum: = also 1 carry out

Step 6 After adding two digits, GvR will have some number in the range 0…19 of beepers Check for carry try 9 times to drop a beeper If there is still a beeper in a bag, then there is a carry out. Otherwise, there is no carry out.

Step 7 no_carry_out The sum result should be the right place No need to do extra steps So, just move the robot to the next column (1E, 3N, 1E) carry_out Pick up all beepers. Move south to drop 9 beepers in the garbage space. Move 2 west and 1 north to drop 1 beeper (carry). Move 2 east back to drop the all beepers in the bag. Demo lab_3a_7.gvr

Step 8 Repeat 2 more times to add 3 digits Be sure to pick up the carry if there is one before computing the next sums. Demo lab_3a_complete.gvr

Demo Demo your final program on: lab_3a.wld: = 1235 lab_3a.wld lab_3b.wld: = 43 lab_3b.wld lab_3c.wld: = 1015 lab_3c.wld