Lecture 13. Example. Encapsulation. Rational numbers: a number is rational if it can be defined as the ratio between two integers.

Size: px
Start display at page:

Download "Lecture 13. Example. Encapsulation. Rational numbers: a number is rational if it can be defined as the ratio between two integers."

Transcription

1 Lecture 13 Example Rational numbers: a number is rational if it can be defined as the ratio between two integers Issues in object-oriented programming The class Rational completed Material from Holmes Chapter 7: sections 1 through to 4, except section 6 (nothing explicitly about this in Hubbard), the ratio of the length of a circle circumference to its diameter, is a classical example of non-rational number Note that is also equal to 1 3 A class for the rational numbers class Rational { Encapsulation [Rumbaugh] Encapsulation (or information hiding) consists of separating the external aspects of an object, which are accessible to other objects, from the internal implementation details of the object, which are hidden from other objects // attributes private int numerator; private int denominator; // constructors public Rational () { numerator = 0; denominator = 1; public Rational ( int num, int denom) { numerator = num; denominator = denom; // reduces the fraction to its simplest form 2 3-1

2 Methods Revisited The variables numerator denominator are private to a rational number object They can only be accessed through methods defined in the class To display a rational number one should add a method similar to the following to the class Rational: public void printfraction () { if (denominator == 1) Systemoutprintln(numerator); else Systemoutprintln(numerator + "/" + denominator); Remarks Initial definitions: Rational a = new Rational(1,2); Rational b = new Rational(3,4); Rational c; Information hiding: the user only types cadd(a,b) doesn t need to know that a rational is implemented as a pair Inside the method: The use of xnumerator it is fine inside the class Outside the class there should not be any reference to the class private attributes this identifies the object itself It may be needed when the method has to return an object of the same type 4 6 To add two rationals to produce another rational we follow the rule then simplify the result Object Properties Since objects are stored by reference equality assignment operations need to be hled with some care If a b are two objects in the same class a = b a == b only deal with the object pointers not with their values // Equality between the given rational another one public Rational add ( Rational x, Rational y) { numerator = xnumerator * ydenominator + ynumerator * xdenominator; denominator = xdenominator * ydenominator; <=== reference to the object itself! public boolean equals ( Rational x ) { return (( thisnumerator == xnumerator ) && ( thisdenominator == xdenominator)); Rational a, b = new Rational( 2, 3 ); a = b; 5 7

3 // Copying objects Rational a, b = new Rational( 2, 3 ); a = b; // This only sets the pointers! // Damaging side effect: // changes to b imply chnges to a! public Rational copy () { Rational x = new Rational ( thisnumerator, thisdenominator ); return x; a = bcopy(); Class analysis The external structure of the class Rational is described below class Rational { // attributes private int numerator; private int denominator; // constructors public Rational (); public Rational ( int num, int denum ); // methods public Rational add ( Rational x, Rational y ); public Rational subtract ( Rational x, Rational y ); public Rational multiply ( Rational x, Rational y ); public Rational divide ( Rational x, Rational y ); public void printfraction (); public boolean equals ( Rational x ); public Rational copy (); Rational numerator denominator add ( Rationalx, Rational y) subtract ( Rational x, Rational y) multiply ( Rational x, Rational y) divide ( Rational x, Rational y) printfraction () equals copy () 8 10 Case Study: Arithmetic of Rational Numbers Problem Devise a Java class for the rational numbers Define methods to perform the four arithmetic operations on two rational numbers Also, define methods to print a rational number, copy a rational number compare two numbers for equality Problem analysis The operations on rationals are defined as follows: Algorithm Design Most of the methods above have already been implemented We just need to add some pseudo-code for a gcd algorithm for makerational Rationals should be expressed in minimal form A rational is reduced in minimal form by finding gcd dividing but by this number We ll call makerational this function 9 11

4 Example Euclid GCD algorithm Let, This is probably the oldest algorithm ever It is described as the solution to Proposition VII2 in Euclid s Elements: djoyce/java/elements/tochtml Given two numbers not prime to one another, to find their greatest common measure 2322 = 654* gcd 654 = 360* gcd 360 = 294* gcd 294 = 66* gcd 66 = 30*2 + 6 gcd 30 = 6*5 gcd gcd gcd gcd gcd gcd Therefore, gcd Problem Analysis The algorithm is based on the following two observations: 1 If then gcd This is indeed so because no number (, in particular) may have a divisor greater than the number itself (I am talking here of non-negative integers) 2 If, for integers, then gcd gcd Indeed, every common divisor of a b also divides r Thus gcd divides gcd is a common divisor of hence gcd gcd The reverse is also true because every divisor of also divides But, of course, gcd Therefore, Algorithm for the greatest common divisor 1 divideby find remainder 2 while remainder is not zero 3 assign to 4 assign remainder to 5 divideby find remainder 6 assign to gcd 13 15

5 Algorithm for minimising a rational number 1 calculate gcd for a given 2 divide by gcd 3 divide by gcd 4 if either is zero 5 assign to 6 else 7 calculate the gcd for absolute values of 8 if 9 divide by gcd 10 divide by gcd 11 else 12 divide by negative gcd 13 divide by negative gcd or private void makerational() { int gcd; int divisor = 0; gcd = greatestcommondivisor(numerator, denominator); numerator = numerator / gcd; denominator = denominator / gcd; if (numerator == 0 denominator == 0) denominator = Mathabs(denominator); else { divisor = greatestcommondivisor(mathabs(numerator), Mathabs(denominator)); if (denominator > 0) { numerator = numerator / divisor; denominator = denominator / divisor; else { numerator = numerator / (-divisor); denominator = denominator / (-divisor); // chap_7\ex_1java // program to test the methods of the rational class import javaio*; class Rational { private int numerator; private int denominator; // private methods, not to be seen from the outside private int greatestcommondivisor(int n, int d) { int remainder = n % d; while (remainder!= 0) { n = d; d = remainder; remainder = n % d; return d; // constructors public Rational() { numerator = 0; denominator = 1; public Rational(int num, int denom) { numerator = num; denominator = denom; // methods public Rational add(rational x, Rational y)d { numerator = xnumerator * ydenominator + ynumerator * xdenominator; denominator = xdenominator * ydenominator;

6 public Rational subtract(rational x, Rational y) { numerator = xnumerator * ydenominator - ynumerator * xdenominator; denominator = xdenominator * ydenominator; public Rational multiply(rational x, Rational y) { numerator = xnumerator * ynumerator; denominator = xdenominator * ydenominator; public Rational divide(rational x, Rational y) { numerator = xnumerator * ydenominator; denominator = xdenominator * ynumerator; class Ex_1 { public static void main(string[] args) throws IOException { Rational a = new Rational(-8,3); Rational b = new Rational(9,4); Rational c = new Rational(); Rational d; Systemoutprint("a="); aprintfraction(); Systemoutprint("b="); bprintfraction(); Systemoutprint("a+b="); cadd(a,b)printfraction(); Systemoutprint("a-b="); csubtract(a,b)printfraction(); Systemoutprint("a*b="); cmultiply(a,b)printfraction(); Systemoutprint("a/b="); cdivide(a,b)printfraction(); d=acopy(); Systemoutprint("d="); dprintfraction(); if (dequals(a)) Systemoutprintln("Both d a are equal"); public void printfraction() { if (denominator == 1) Systemoutprintln(numerator); else Systemoutprintln(numerator + "/" + denominator); public boolean equals(rational x) { return ((thisnumerator == xnumerator) && (thisdenominator == xdenominator)); public Rational copy() { Rational temporary = new Rational(thisnumerator, thisdenominator); return temporary; Exercises 1 Draw a class diagram for the code in the example above 2 Extend the class Rational by implementing a between two rational numbers relation 3 To improve the accuracy of the numerical calculation involved replace int with long This should be transparent to the user 4 Repeat similar construction for complex numbers This is exercise 36 on page

AP Computer Science. TextLab05 Java Assignment. Assignment Purpose: Do not copy this file, which is provided. TextLab05 Student Version

AP Computer Science. TextLab05 Java Assignment. Assignment Purpose: Do not copy this file, which is provided. TextLab05 Student Version AP Computer Science The Rational Class Program II TextLab05 Java Assignment 80, 90 & 100 Point Versions Assignment Purpose: The purpose of this lab is to demonstrate knowledge of creating a class with

More information

Carleton University Department of Systems and Computer Engineering SYSC Foundations of Imperative Programming - Winter Lab 8 - Structures

Carleton University Department of Systems and Computer Engineering SYSC Foundations of Imperative Programming - Winter Lab 8 - Structures Carleton University Department of Systems and Computer Engineering SYSC 2006 - Foundations of Imperative Programming - Winter 2012 Lab 8 - Structures Objective To write functions that manipulate structures.

More information

CISC 3115 Modern Programming Techniques Spring 2018 Section TY3 Exam 2 Solutions

CISC 3115 Modern Programming Techniques Spring 2018 Section TY3 Exam 2 Solutions Name CISC 3115 Modern Programming Techniques Spring 2018 Section TY3 Exam 2 Solutions 1. a. (25 points) A rational number is a number that can be represented by a pair of integers a numerator and a denominator.

More information

CIT 590 Homework 6 Fractions

CIT 590 Homework 6 Fractions CIT 590 Homework 6 Fractions Purposes of this assignment: Get you started in Java and Eclipse Get you comfortable using objects in Java Start looking at some common object uses in Java. General Idea of

More information

Rational numbers as decimals and as integer fractions

Rational numbers as decimals and as integer fractions Rational numbers as decimals and as integer fractions Given a rational number expressed as an integer fraction reduced to the lowest terms, the quotient of that fraction will be: an integer, if the denominator

More information

Object Oriented Modeling

Object Oriented Modeling Object Oriented Modeling Object oriented modeling is a method that models the characteristics of real or abstract objects from application domain using classes and objects. Objects Software objects are

More information

Object Oriented Programming COP3330 / CGS5409

Object Oriented Programming COP3330 / CGS5409 Object Oriented Programming COP3330 / CGS5409 Classes & Objects DDU Design Constructors Member Functions & Data Friends and member functions Const modifier Destructors Object -- an encapsulation of data

More information

Recitation #2 Abstract Data Types, Collection Classes, and Linked List

Recitation #2 Abstract Data Types, Collection Classes, and Linked List Recitation #2 Abstract Data Types, Collection Classes, and Linked List (1) Create an ADT Fraction that describes properties of fractions. Include the constructor, setter, getter, and tostring() methods

More information

1 Elementary number theory

1 Elementary number theory Math 215 - Introduction to Advanced Mathematics Spring 2019 1 Elementary number theory We assume the existence of the natural numbers and the integers N = {1, 2, 3,...} Z = {..., 3, 2, 1, 0, 1, 2, 3,...},

More information

- 0.8.00-0.8. 7 ANSWERS: ) : ) : ) : ) : 8 RATIO WORD PROBLEM EXAMPLES: Ratio Compares two amounts or values; they can be written in ways. As a fraction With a colon : With words to A classroom has girls

More information

Creating a new data type

Creating a new data type Appendix B Creating a new data type Object-oriented programming languages allow programmers to create new data types that behave much like built-in data types. We will explore this capability by building

More information

SOLUTION: Because the fractions have a common denominator, compare the numerators. 5 < 3

SOLUTION: Because the fractions have a common denominator, compare the numerators. 5 < 3 Section 1 Practice Problems 1. Because the fractions have a common denominator, compare the numerators. 5 < 3 So,. 2. 0.71 To compare these numbers, write both fractions as a decimal. 0.8 is greater than

More information

CW Middle School. Math RtI 7 A. 4 Pro cient I can add and subtract positive fractions with unlike denominators and simplify the result.

CW Middle School. Math RtI 7 A. 4 Pro cient I can add and subtract positive fractions with unlike denominators and simplify the result. 1. Foundations (14.29%) 1.1 I can add and subtract positive fractions with unlike denominators and simplify the result. 4 Pro cient I can add and subtract positive fractions with unlike denominators and

More information

EE 152 Advanced Programming LAB 7

EE 152 Advanced Programming LAB 7 EE 152 Advanced Programming LAB 7 1) Create a class called Rational for performing arithmetic with fractions. Write a program to test your class. Use integer variables to represent the private data of

More information

Euclid's Algorithm. MA/CSSE 473 Day 06. Student Questions Odd Pie Fight Euclid's algorithm (if there is time) extended Euclid's algorithm

Euclid's Algorithm. MA/CSSE 473 Day 06. Student Questions Odd Pie Fight Euclid's algorithm (if there is time) extended Euclid's algorithm MA/CSSE 473 Day 06 Euclid's Algorithm MA/CSSE 473 Day 06 Student Questions Odd Pie Fight Euclid's algorithm (if there is time) extended Euclid's algorithm 1 Quick look at review topics in textbook REVIEW

More information

LAB 7. Objectives: Navin Sridhar D 8 54

LAB 7. Objectives: Navin Sridhar D 8 54 LAB 7 Objectives: 1. Learn to create and define constructors. 2. Understand the use and application of constructors & instance variables. 3. Experiment with the various properties of arrays. 4. Learn to

More information

Section 2.3 Rational Numbers. A rational number is a number that may be written in the form a b. for any integer a and any nonzero integer b.

Section 2.3 Rational Numbers. A rational number is a number that may be written in the form a b. for any integer a and any nonzero integer b. Section 2.3 Rational Numbers A rational number is a number that may be written in the form a b for any integer a and any nonzero integer b. Why is division by zero undefined? For example, we know that

More information

6th Grade Arithmetic (with QuickTables)

6th Grade Arithmetic (with QuickTables) 6th Grade Arithmetic (with QuickTables) This course covers the topics shown below. Students navigate learning paths based on their level of readiness. Institutional users may customize the scope and sequence

More information

Odd-Numbered Answers to Exercise Set 1.1: Numbers

Odd-Numbered Answers to Exercise Set 1.1: Numbers Odd-Numbered Answers to Exercise Set.: Numbers. (a) Composite;,,, Prime Neither (d) Neither (e) Composite;,,,,,. (a) 0. 0. 0. (d) 0. (e) 0. (f) 0. (g) 0. (h) 0. (i) 0.9 = (j). (since = ) 9 9 (k). (since

More information

Lesson 1: Arithmetic Review

Lesson 1: Arithmetic Review In this lesson we step back and review several key arithmetic topics that are extremely relevant to this course. Before we work with algebraic expressions and equations, it is important to have a good

More information

CSc 372 Comparative Programming Languages

CSc 372 Comparative Programming Languages CSc 372 Comparative Programming Languages 8 : Haskell Function Examples Christian Collberg collberg+372@gmail.com Department of Computer Science University of Arizona Copyright c 2005 Christian Collberg

More information

CSc 372. Comparative Programming Languages. 8 : Haskell Function Examples. Department of Computer Science University of Arizona

CSc 372. Comparative Programming Languages. 8 : Haskell Function Examples. Department of Computer Science University of Arizona 1/43 CSc 372 Comparative Programming Languages 8 : Haskell Function Examples Department of Computer Science University of Arizona collberg@gmail.com Copyright c 2013 Christian Collberg Functions over Lists

More information

Integers and Rational Numbers

Integers and Rational Numbers A A Family Letter: Integers Dear Family, The student will be learning about integers and how these numbers relate to the coordinate plane. The set of integers includes the set of whole numbers (0, 1,,,...)

More information

Mini-Lesson 1. Section 1.1: Order of Operations PEMDAS

Mini-Lesson 1. Section 1.1: Order of Operations PEMDAS Name: Date: 1 Section 1.1: Order of Operations PEMDAS If we are working with a mathematical expression that contains more than one operation, then we need to understand how to simplify. The acronym PEMDAS

More information

Number- Algebra. Problem solving Statistics Investigations

Number- Algebra. Problem solving Statistics Investigations Place Value Addition, Subtraction, Multiplication and Division Fractions Position and Direction Decimals Percentages Algebra Converting units Perimeter, Area and Volume Ratio Properties of Shapes Problem

More information

1. Download the JDK 6, from

1. Download the JDK 6, from 1. Install the JDK 1. Download the JDK 6, from http://java.sun.com/javase/downloads/widget/jdk6.jsp. 2. Once the file is completed downloaded, execute it and accept the license agreement. 3. Select the

More information

Lecture Overview Code generation in milestone 2 o Code generation for array indexing o Some rational implementation Over Express Over o Creating

Lecture Overview Code generation in milestone 2 o Code generation for array indexing o Some rational implementation Over Express Over o Creating 1 ecture Overview Code generation in milestone 2 o Code generation for array indexing o Some rational implementation Over Express Over o Creating records for arrays o Short-circuiting Or o If statement

More information

struct _Rational { int64_t Top; // numerator int64_t Bottom; // denominator }; typedef struct _Rational Rational;

struct _Rational { int64_t Top; // numerator int64_t Bottom; // denominator }; typedef struct _Rational Rational; Creating a Data Type in C Rational Numbers For this assignment, you will use the struct mechanism in C to implement a data type that represents rational numbers. A set can be modeled using the C struct:

More information

Reteaching. Comparing and Ordering Integers

Reteaching. Comparing and Ordering Integers - Comparing and Ordering Integers The numbers and - are opposites. The numbers 7 and -7 are opposites. Integers are the set of positive whole numbers, their opposites, and zero. 7 6 4 0 negative zero You

More information

Course Learning Outcomes for Unit I. Reading Assignment. Unit Lesson. UNIT I STUDY GUIDE Number Theory and the Real Number System

Course Learning Outcomes for Unit I. Reading Assignment. Unit Lesson. UNIT I STUDY GUIDE Number Theory and the Real Number System UNIT I STUDY GUIDE Number Theory and the Real Number System Course Learning Outcomes for Unit I Upon completion of this unit, students should be able to: 2. Relate number theory, integer computation, and

More information

Rational number operations can often be simplified by converting mixed numbers to improper fractions Add EXAMPLE:

Rational number operations can often be simplified by converting mixed numbers to improper fractions Add EXAMPLE: Rational number operations can often be simplified by converting mixed numbers to improper fractions Add ( 2) EXAMPLE: 2 Multiply 1 Negative fractions can be written with the negative number in the numerator

More information

1 Elementary number theory

1 Elementary number theory 1 Elementary number theory We assume the existence of the natural numbers and the integers N = {1, 2, 3,...} Z = {..., 3, 2, 1, 0, 1, 2, 3,...}, along with their most basic arithmetical and ordering properties.

More information

Rational and Irrational Numbers

Rational and Irrational Numbers LESSON. Rational and Irrational Numbers.NS. Know that numbers that are not rational are called irrational. Understand informally that every number has a decimal expansion;... lso.ns.2,.ee.2? ESSENTIL QUESTION

More information

(3) Some memory that holds a value of a given type. (8) The basic unit of addressing in most computers.

(3) Some memory that holds a value of a given type. (8) The basic unit of addressing in most computers. CS 7A Final Exam - Fall 206 - Final Exam Solutions 2/3/6. Write the number of the definition on the right next to the term it defines. () Defining two functions or operators with the same name but different

More information

MATHEMATICS Key Stage 2 Year 6

MATHEMATICS Key Stage 2 Year 6 MATHEMATICS Key Stage 2 Year 6 Key Stage Strand Objective Child Speak Target Greater Depth Target [EXS] [KEY] Read, write, order and compare numbers up to 10 000 000 and determine the value of each digit.

More information

CS 455 Midterm Exam 1 Fall 2016 [Bono] Thursday, Sept. 29, 2016

CS 455 Midterm Exam 1 Fall 2016 [Bono] Thursday, Sept. 29, 2016 Name: USC NetID (e.g., ttrojan): CS 455 Midterm Exam 1 Fall 2016 [Bono] Thursday, Sept. 29, 2016 There are 5 problems on the exam, with 56 points total available. There are 10 pages to the exam (5 pages

More information

CS 101 Fall 2006 Midterm 3 Name: ID:

CS 101 Fall 2006 Midterm 3 Name:  ID: You only need to write your name and e-mail ID on the first page. This exam is CLOSED text book, closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts, so be sure

More information

Number Mulitplication and Number and Place Value Addition and Subtraction Division

Number Mulitplication and Number and Place Value Addition and Subtraction Division Number Mulitplication and Number and Place Value Addition and Subtraction Division read, write, order and compare numbers up to 10 000 000 and determine the value of each digit round any whole number to

More information

Lesson 1: Arithmetic Review

Lesson 1: Arithmetic Review Lesson 1: Arithmetic Review Topics and Objectives: Order of Operations Fractions o Improper fractions and mixed numbers o Equivalent fractions o Fractions in simplest form o One and zero Operations on

More information

Math Glossary Numbers and Arithmetic

Math Glossary Numbers and Arithmetic Math Glossary Numbers and Arithmetic Version 0.1.1 September 1, 200 Next release: On or before September 0, 200. E-mail edu@ezlink.com for the latest version. Copyright 200 by Brad Jolly All Rights Reserved

More information

CS3110 Spring 2017 Lecture 10 a Module for Rational Numbers

CS3110 Spring 2017 Lecture 10 a Module for Rational Numbers CS3110 Spring 2017 Lecture 10 a Module for Rational Numbers Robert Constable Abstract The notes and lecture start with a brief summary of the relationship between OCaml types, Coq types and logic that

More information

New Swannington Primary School 2014 Year 6

New Swannington Primary School 2014 Year 6 Number Number and Place Value Number Addition and subtraction, Multiplication and division Number fractions inc decimals & % Ratio & Proportion Algebra read, write, order and compare numbers up to 0 000

More information

Java Identifiers, Data Types & Variables

Java Identifiers, Data Types & Variables Java Identifiers, Data Types & Variables 1. Java Identifiers: Identifiers are name given to a class, variable or a method. public class TestingShastra { //TestingShastra is an identifier for class char

More information

JAVA OPERATORS GENERAL

JAVA OPERATORS GENERAL JAVA OPERATORS GENERAL Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Arithmetic Operators Relational Operators Bitwise Operators

More information

Integers are whole numbers; they include negative whole numbers and zero. For example -7, 0, 18 are integers, 1.5 is not.

Integers are whole numbers; they include negative whole numbers and zero. For example -7, 0, 18 are integers, 1.5 is not. What is an INTEGER/NONINTEGER? Integers are whole numbers; they include negative whole numbers and zero. For example -7, 0, 18 are integers, 1.5 is not. What is a REAL/IMAGINARY number? A real number is

More information

141214 20219031 1 Object-Oriented Programming concepts Object-oriented programming ( תכנות מונחה עצמים ) involves programming using objects An object ) (עצם represents an entity in the real world that

More information

Name: Date: Review Packet: Unit 1 The Number System

Name: Date: Review Packet: Unit 1 The Number System Name: Date: Math 7 Ms. Conway Review Packet: Unit 1 The Number System Key Concepts Module 1: Adding and Subtracting Integers 7.NS.1, 7.NS.1a, 7.NS.1b, 7.NS.1c, 7.NS.1d, 7.NS.3, 7.EE.3 To add integers with

More information

Utilities (Part 2) Implementing static features

Utilities (Part 2) Implementing static features Utilities (Part 2) Implementing static features 1 Goals for Today learn about preventing class instantiation learn about methods static methods method header method signature method return type method

More information

Learning Log Title: CHAPTER 3: ARITHMETIC PROPERTIES. Date: Lesson: Chapter 3: Arithmetic Properties

Learning Log Title: CHAPTER 3: ARITHMETIC PROPERTIES. Date: Lesson: Chapter 3: Arithmetic Properties Chapter 3: Arithmetic Properties CHAPTER 3: ARITHMETIC PROPERTIES Date: Lesson: Learning Log Title: Date: Lesson: Learning Log Title: Chapter 3: Arithmetic Properties Date: Lesson: Learning Log Title:

More information

The Java language has a wide variety of modifiers, including the following:

The Java language has a wide variety of modifiers, including the following: PART 5 5. Modifier Types The Java language has a wide variety of modifiers, including the following: Java Access Modifiers Non Access Modifiers 5.1 Access Control Modifiers Java provides a number of access

More information

Week 3: Functions and Data

Week 3: Functions and Data Week 3: Functions and Data In this section, we'll learn how functions create and encapsulate data structures. Exemple : Rational Numbers We want to design a package for doing rational arithmetic. A rational

More information

Chapter 4 Section 2 Operations on Decimals

Chapter 4 Section 2 Operations on Decimals Chapter 4 Section 2 Operations on Decimals Addition and subtraction of decimals To add decimals, write the numbers so that the decimal points are on a vertical line. Add as you would with whole numbers.

More information

Imperative Languages!

Imperative Languages! Imperative Languages! Java is an imperative object-oriented language. What is the difference in the organisation of a program in a procedural and an objectoriented language? 30 class BankAccount { private

More information

Section A Arithmetic ( 5) Exercise A

Section A Arithmetic ( 5) Exercise A Section A Arithmetic In the non-calculator section of the examination there might be times when you need to work with quite awkward numbers quickly and accurately. In particular you must be very familiar

More information

Unit: Rational Number Lesson 3.1: What is a Rational Number? Objectives: Students will compare and order rational numbers.

Unit: Rational Number Lesson 3.1: What is a Rational Number? Objectives: Students will compare and order rational numbers. Unit: Rational Number Lesson 3.: What is a Rational Number? Objectives: Students will compare and order rational numbers. (9N3) Procedure: This unit will introduce the concept of rational numbers. This

More information

User-built data types Mutable and immutable data

User-built data types Mutable and immutable data Chapter 18 User-built data types Mutable and immutable data In some cases the kind of data that a program uses is not provided as a built-in data type by the language. Then a data type can be programmed:

More information

Chapter 1 An Introduction to Computer Science. INVITATION TO Computer Science 1

Chapter 1 An Introduction to Computer Science. INVITATION TO Computer Science 1 Chapter 1 An Introduction to Computer Science INVITATION TO Computer Science 1 Q8. Under what conditions would the well-known quadratic formula not be effectively computable? (Assume that you are working

More information

50 MATHCOUNTS LECTURES (6) OPERATIONS WITH DECIMALS

50 MATHCOUNTS LECTURES (6) OPERATIONS WITH DECIMALS BASIC KNOWLEDGE 1. Decimal representation: A decimal is used to represent a portion of whole. It contains three parts: an integer (which indicates the number of wholes), a decimal point (which separates

More information

Fractions. Dividing the numerator and denominator by the highest common element (or number) in them, we get the fraction in its lowest form.

Fractions. Dividing the numerator and denominator by the highest common element (or number) in them, we get the fraction in its lowest form. Fractions A fraction is a part of the whole (object, thing, region). It forms the part of basic aptitude of a person to have and idea of the parts of a population, group or territory. Civil servants must

More information

CSE 142 Su 04 Computer Programming 1 - Java. Objects

CSE 142 Su 04 Computer Programming 1 - Java. Objects Objects Objects have state and behavior. State is maintained in instance variables which live as long as the object does. Behavior is implemented in methods, which can be called by other objects to request

More information

UCT Algorithm Circle: Number Theory

UCT Algorithm Circle: Number Theory UCT Algorithm Circle: 7 April 2011 Outline Primes and Prime Factorisation 1 Primes and Prime Factorisation 2 3 4 Some revision (hopefully) What is a prime number? An integer greater than 1 whose only factors

More information

1.1 The Real Number System

1.1 The Real Number System 1.1 The Real Number System Contents: Number Lines Absolute Value Definition of a Number Real Numbers Natural Numbers Whole Numbers Integers Rational Numbers Decimals as Fractions Repeating Decimals Rewriting

More information

Introduction to Programming in C Department of Computer Science and Engineering\ Lecture No. #02 Introduction: GCD

Introduction to Programming in C Department of Computer Science and Engineering\ Lecture No. #02 Introduction: GCD Introduction to Programming in C Department of Computer Science and Engineering\ Lecture No. #02 Introduction: GCD In this session, we will write another algorithm to solve a mathematical problem. If you

More information

COMPSCI 105 S Principles of Computer Science. Classes 3

COMPSCI 105 S Principles of Computer Science. Classes 3 S2 2017 Principles of Computer Science Classes 3 Exercise } Exercise } Create a Student class: } The Student class should have three attributes: id, last_name, and first_name. } Create a constructor to

More information

Computer Programming, I. Laboratory Manual. Experiment #3. Selections

Computer Programming, I. Laboratory Manual. Experiment #3. Selections Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Experiment #3

More information

Oral and Mental calculation

Oral and Mental calculation Oral and Mental calculation Read and write any integer and know what each digit represents. Read and write decimal notation for tenths, hundredths and thousandths and know what each digit represents. Order

More information

Fraction to Percents Change the fraction to a decimal (see above) and then change the decimal to a percent (see above).

Fraction to Percents Change the fraction to a decimal (see above) and then change the decimal to a percent (see above). PEMDAS This is an acronym for the order of operations. Order of operations is the order in which you complete problems with more than one operation. o P parenthesis o E exponents o M multiplication OR

More information

Expected Standards for Year 6: Mathematics Curriculum (taken from ncetm progression maps)

Expected Standards for Year 6: Mathematics Curriculum (taken from ncetm progression maps) Expected Standards for Year 6: Mathematics Curriculum (taken from ncetm progression maps) Place Value Addition and Subtraction Multiplication and Division Fractions Ratio and Proportion Measurement Geometry

More information

ARITHMETIC EXPRESSION

ARITHMETIC EXPRESSION Section 1: Expression & Terms MATH LEVEL 2 LESSON PLAN 1 ARITHMETIC EXPRESSION 2017 Copyright Vinay Agarwala, Revised: 10/31/17 1. An arithmetic expression is made up of numbers joined by addition (+),

More information

Year 6 Term 1 and

Year 6 Term 1 and Year 6 Term 1 and 2 2016 Points in italics are either where statements have been moved from other year groups or to support progression where no statement is given Oral and Mental calculation Read and

More information

Coding Standards for Java

Coding Standards for Java Why have coding standards? Coding Standards for Java Version 1.3 It is a known fact that 80% of the lifetime cost of a piece of software goes to maintenance; therefore, it makes sense for all programs

More information

COSC 243. Data Representation 3. Lecture 3 - Data Representation 3 1. COSC 243 (Computer Architecture)

COSC 243. Data Representation 3. Lecture 3 - Data Representation 3 1. COSC 243 (Computer Architecture) COSC 243 Data Representation 3 Lecture 3 - Data Representation 3 1 Data Representation Test Material Lectures 1, 2, and 3 Tutorials 1b, 2a, and 2b During Tutorial a Next Week 12 th and 13 th March If you

More information

Year 6 Maths Long Term Plan

Year 6 Maths Long Term Plan Week & Focus 1 Number and Place Value Unit 1 2 Subtraction Value Unit 1 3 Subtraction Unit 3 4 Subtraction Unit 5 5 Unit 2 6 Division Unit 4 7 Fractions Unit 2 Autumn Term Objectives read, write, order

More information

A Fraction Class. Using a Fraction class, we can compute the above as: Assignment Objectives

A Fraction Class. Using a Fraction class, we can compute the above as: Assignment Objectives A Fraction Class Assignment Objectives What to Submit Evaluation Individual Work Write a Fraction class that performs exact fraction arithmetic. 1. Practice fundamental methods like equals, tostring, and

More information

Total 100. The American University in Cairo Computer Science & Engineering Department CSCE 106. Instructor: Final Exam Fall Section No.

Total 100. The American University in Cairo Computer Science & Engineering Department CSCE 106. Instructor: Final Exam Fall Section No. The American University in Cairo Computer Science & Engineering Department CSCE 106 Instructor: Final Exam Fall 2010 Last Name :... ID:... First Name:... Section No.: EXAMINATION INSTRUCTIONS * Do not

More information

5.5 Complex Fractions

5.5 Complex Fractions 5.5 Complex Fractions At this point, right after we cover all the basic operations, we would usually turn our attention to solving equations. However, there is one other type of rational expression that

More information

Year 6.1- Number and Place Value 2 weeks- Autumn 1 Read, write, order and compare numbers up to and determine the value of each digit.

Year 6.1- Number and Place Value 2 weeks- Autumn 1 Read, write, order and compare numbers up to and determine the value of each digit. Year 6.1- Number and Place Value 2 weeks- Autumn 1 Read, write, order and compare numbers up to 10 000 000 and determine the value of each digit. Round any whole number to a required degree of accuracy.

More information

5.6 Rational Equations

5.6 Rational Equations 5.6 Rational Equations Now that we have a good handle on all of the various operations on rational expressions, we want to turn our attention to solving equations that contain rational expressions. The

More information

About This Lecture. Outline. Handling Unusual Situations. Reacting to errors. Exceptions

About This Lecture. Outline. Handling Unusual Situations. Reacting to errors. Exceptions Exceptions Revised 24-Jan-05 CMPUT 115 - Lecture 4 Department of Computing Science University of Alberta About This Lecture In this lecture we will learn how to use Java Exceptions to handle unusual program

More information

CMSC 132, Object-Oriented Programming II Summer Lecture 1:

CMSC 132, Object-Oriented Programming II Summer Lecture 1: CMSC 132, Object-Oriented Programming II Summer 2018 Lecturer: Anwar Mamat Lecture 1: Disclaimer: These notes may be distributed outside this class only with the permission of the Instructor. 1.1 Course

More information

A.4 Rationalizing the Denominator

A.4 Rationalizing the Denominator A.4 Rationalizing the Denominator RATIONALIZING THE DENOMINATOR A.4 Rationalizing the Denominator If a radical expression contains an irrational denominator, such as,, or 0, then it is not considered to

More information

CSCE 110: Programming I

CSCE 110: Programming I CSCE 110: Programming I Sample Questions for Exam #1 February 17, 2013 Below are sample questions to help you prepare for Exam #1. Make sure you can solve all of these problems by hand. For most of the

More information

Slide 1 / 180. Radicals and Rational Exponents

Slide 1 / 180. Radicals and Rational Exponents Slide 1 / 180 Radicals and Rational Exponents Slide 2 / 180 Roots and Radicals Table of Contents: Square Roots Intro to Cube Roots n th Roots Irrational Roots Rational Exponents Operations with Radicals

More information

Year 6 Mathematics Overview

Year 6 Mathematics Overview Year 6 Mathematics Overview Term Strand National Curriculum 2014 Objectives Focus Sequence Autumn 1 Number and Place Value read, write, order and compare numbers up to 10 000 000 and determine the value

More information

Intro to Rational Expressions

Intro to Rational Expressions Intro to Rational Expressions Fractions and Exponents Review Fractions Review Adding and Subtracting Fractions Always find a common denominator when adding or subtracting fractions! a) b) Multiplying and

More information

Technical Section. Lab 4 while loops and for loops. A. while Loops or for loops

Technical Section. Lab 4 while loops and for loops. A. while Loops or for loops Lab 4 while loops and for loops The purpose of this lab is to introduce you to the concept of a for loop, gain experience distinguishing between a while loop (which is a more general type of loop than

More information

TACi: Three-Address Code Interpreter (version 1.0)

TACi: Three-Address Code Interpreter (version 1.0) TACi: Three-Address Code Interpreter (version 1.0) David Sinclair September 23, 2018 1 Introduction TACi is an interpreter for Three-Address Code, the common intermediate representation (IR) used in compilers.

More information

Midterm I - CSE11 Fall 2013 CLOSED BOOK, CLOSED NOTES 50 minutes, 100 points Total.

Midterm I - CSE11 Fall 2013 CLOSED BOOK, CLOSED NOTES 50 minutes, 100 points Total. Midterm I - CSE11 Fall 2013 CLOSED BOOK, CLOSED NOTES 50 minutes, 100 points Total. Name: ID: Problem 1) (8 points) For the following code segment, what are the values of i, j, k, and d, after the segment

More information

EXAMPLE 1. Change each of the following fractions into decimals.

EXAMPLE 1. Change each of the following fractions into decimals. CHAPTER 1. THE ARITHMETIC OF NUMBERS 1.4 Decimal Notation Every rational number can be expressed using decimal notation. To change a fraction into its decimal equivalent, divide the numerator of the fraction

More information

Number and Place Value

Number and Place Value Number and Place Value Reading and writing numbers Ordering and comparing numbers Place value Representing and estimating numbers Rounding numbers Counting Finding other numbers Solving problems Roman

More information

1.00 Lecture 4. Promotion

1.00 Lecture 4. Promotion 1.00 Lecture 4 Data Types, Operators Reading for next time: Big Java: sections 6.1-6.4 Promotion increasing capacity Data Type Allowed Promotions double None float double long float,double int long,float,double

More information

Objective A Identify the numerator and the denominator of a fraction. When the numerator is less than the denominator, it is a(n) fraction.

Objective A Identify the numerator and the denominator of a fraction. When the numerator is less than the denominator, it is a(n) fraction. Prealgebra Seventh Edition, Elayn Martin-Gay Sec. 4. Section 4. Introduction to Fractions and Mixed Numbers Complete the outline as you view Lecture Video 4.. Pause the video as needed to fill in all blanks.

More information

3.1 Dividing a Whole into Fractional Parts. 3.1 Dividing a Set into Fractional Parts. 3.2 Identifying Parts of Wholes.

3.1 Dividing a Whole into Fractional Parts. 3.1 Dividing a Set into Fractional Parts. 3.2 Identifying Parts of Wholes. . Dividing a Whole into Fractional Parts Fraction: represents a part of a whole object or unit Numerator: (top number) represents number of parts of the whole Denominator: (bottom number) represents how

More information

Is the statement sufficient? If both x and y are odd, is xy odd? 1) xy 2 < 0. Odds & Evens. Positives & Negatives. Answer: Yes, xy is odd

Is the statement sufficient? If both x and y are odd, is xy odd? 1) xy 2 < 0. Odds & Evens. Positives & Negatives. Answer: Yes, xy is odd Is the statement sufficient? If both x and y are odd, is xy odd? Is x < 0? 1) xy 2 < 0 Positives & Negatives Answer: Yes, xy is odd Odd numbers can be represented as 2m + 1 or 2n + 1, where m and n are

More information

Lecture 6. Drinking. Nested if. Nested if s reprise. The boolean data type. More complex selection statements: switch. Examples.

Lecture 6. Drinking. Nested if. Nested if s reprise. The boolean data type. More complex selection statements: switch. Examples. // Simple program to show how an if- statement works. import java.io.*; Lecture 6 class If { static BufferedReader keyboard = new BufferedReader ( new InputStreamReader( System.in)); public static void

More information

HOW TO DIVIDE: MCC6.NS.2 Fluently divide multi-digit numbers using the standard algorithm. WORD DEFINITION IN YOUR WORDS EXAMPLE

HOW TO DIVIDE: MCC6.NS.2 Fluently divide multi-digit numbers using the standard algorithm. WORD DEFINITION IN YOUR WORDS EXAMPLE MCC6.NS. Fluently divide multi-digit numbers using the standard algorithm. WORD DEFINITION IN YOUR WORDS EXAMPLE Dividend A number that is divided by another number. Divisor A number by which another number

More information

For Module 2 SKILLS CHECKLIST. Fraction Notation. George Hartas, MS. Educational Assistant for Mathematics Remediation MAT 025 Instructor

For Module 2 SKILLS CHECKLIST. Fraction Notation. George Hartas, MS. Educational Assistant for Mathematics Remediation MAT 025 Instructor Last Updated: // SKILLS CHECKLIST For Module Fraction Notation By George Hartas, MS Educational Assistant for Mathematics Remediation MAT 0 Instructor Assignment, Section. Divisibility SKILL: Determine

More information

Y6 MATHEMATICS TERMLY PATHWAY NUMBER MEASURE GEOMETRY STATISTICS

Y6 MATHEMATICS TERMLY PATHWAY NUMBER MEASURE GEOMETRY STATISTICS Autumn Number & Place value read, write, order and compare numbers up to 10 000 000 and determine the value of each digit round any whole number to a required degree of accuracy use negative numbers in

More information

Number System. Introduction. Natural Numbers (N) Whole Numbers (W) Integers (Z) Prime Numbers (P) Face Value. Place Value

Number System. Introduction. Natural Numbers (N) Whole Numbers (W) Integers (Z) Prime Numbers (P) Face Value. Place Value 1 Number System Introduction In this chapter, we will study about the number system and number line. We will also learn about the four fundamental operations on whole numbers and their properties. Natural

More information

A Proposal 1 to add the Infinite Precision Integer and Rational to the C ++ Standard Library

A Proposal 1 to add the Infinite Precision Integer and Rational to the C ++ Standard Library A Proposal 1 to add the Infinite Precision Integer and Rational to the C ++ Standard Library M.J. Kronenburg e-mail: M.Kronenburg@inter.nl.net 1 November 2004 1 Document number N1718=04-0138 ii Contents

More information