Introduction to Computer Programming, Spring Term 2018 Practice Assignment 1 Discussion:

Size: px
Start display at page:

Download "Introduction to Computer Programming, Spring Term 2018 Practice Assignment 1 Discussion:"

Transcription

1 German University in Cairo Media Engineering and Technology Prof. Dr. Slim Abdennadher Dr. Mohammed Abdel Megeed Introduction to Computer Programming, Spring Term 2018 Practice Assignment 1 Discussion: Exercise 1-1 Java Expressions To be discussed in the Lab a) ( 1) Syntactically correct, value 1. b) 1 Syntactically incorrect. is an operator in Java that only works on variables. Correct uses of this operator (and the related ++ operator) are: ++i, i, i++, and i. c) 2 4( 6) Syntactically incorrect. There is an operator missing between 4 and (-6). d) (12) (4) 6 Syntactically correct, value 42. e) 29%5%3 4 2 Syntactically correct, value 2. f) 29%5%3 4 2 Syntactically correct, value -7. g) 7%3 = 1 Syntactically Incorrect. The assignment operator operator ==. = requires a variable on the left side. Danger of confusion with the equality h) 1 / 0 Syntactically correct, run-time error. 1

2 i) 1 / 0.0 Syntactically correct, value infinity. j) ((10 2) 4%)8) Syntactically incorrect, ) expected. k) c h a r c = a ; i n t x = c ; System. o u t. p r i n t l n ( x ) ; x ++; System. o u t. p r i n t l n ( x ) ; c h a r v = ( c h a r ) x ; System. o u t. p r i n t l n ( c ) ; System. o u t. p r i n t l n ( v ) ; c ++; System. o u t. p r i n t l n ( c ) ; Syntactically correct. l) f l o a t x = 2. 5 ; f l o a t y = 3. 4 ; f l o a t z = x + y ; System. o u t. p r i n t ( " The v a l u e i s " + z ) ; Syntactically incorrect. By default in Java, a floating point number is represented as double with 64-bits. Thus, we can not put a double in float without writing the f suffix. m) i n t x = ; long y = ; long z = x + y ; System. o u t. p r i n t l n ( " The v a l u e i s " + z ) ; y = ; z = x + y ; System. o u t. p r i n t ( " The v a l u e i s " + z ) ; Syntactically incorrect. By default in Java, a literal for integers is an int with 32-bits. If we want to store a number like that exceeds the range of the int, we need to write the l suffix.. n) b y t e x = 1 2 ; b y t e y = 8 ; b y t e z = x + y ; System. o u t. p r i n t ( " The v a l u e i s " + z ) ; Syntactically incorrect. On the hardware level the + operation is done on int values. Thus, we need to typecast it into byte as well. 2

3 o) S t r i n g x = "CSEN " ; i n t y = 2 02; S t r i n g z = x + y + "! " ; System. o u t. p r i n t l n ( z ) ; S t r i n g u = y + x + "! " ; System. o u t. p r i n t l n ( u ) ; S t r i n g v = y ; System. o u t. p r i n t l n ( v ) ; S t r i n g m = " " ; i n t o = m; System. o u t. p r i n t l n ( o ) ; Syntactically incorrect. int can not be converted into String, we need to concatenate it to a String. Also, String can not be converted into int directly, we need to parse it. Exercise 1-2 Errors and Conventions To be discussed in the lab In the following lab exercises, follow the instructions carefully and observe the outcome. In each case you should be able to explain why the output is as it is. You are encouraged to check out the useful links on MET Website For each of the.java classes in the Lab 1 Exercises.zip zipped folder, compile the files on JCreator. You are asked to define in each file the lines which have the following faults: a) Syntax Errors b) Runtime Errors c) Logic Errors Furthermore, specifically define the errors. For example, the following line of code: String Word = "Hello World!"; system.out.print(word) has two Syntax Errors and 1 bad identifier naming. The correct solution is: String word = "Hello World!"; System.out.println(word); Exercise 1-3 Number Precision, Exactness To be discussed in the Lab Given the snippet of code below, what will be the values of d3 and d4 that will be printed? double d1 = ; double d2 = ; double d3 = d1 d2 ; System. o u t. p r i n t l n ( d3 ) ; double d4 = 0. 1 ; 3

4 f l o a t f = ( f l o a t ) d4 ; d4 = 1 f ; System. o u t. p r i n t l n ( d4 ) ; d3 will equal , and d4 will equal Exercise 1-4 Picking a random card To be discussed in the lab Given a deck of 1000 cards, you would like to pick the n t h card where n is a random number. You should try out the following two methods: Math.random() as discussed in the lecture. i m p o r t j a v a. u t i l. ; p u b l i c c l a s s PA1 p u b l i c s t a t i c v oid main ( S t r i n g [ ] a r g s ) i n t x = ( i n t ) ( ( Math. random ( ) ) + 1 ) ; System. o u t. p r i n t l n ( x ) ; nextint(int x) where x is the upper bound of the range (exclusive). Hint: it is used with a Random type variable. i m p o r t j a v a. u t i l. ; p u b l i c c l a s s PA1 p u b l i c s t a t i c v oid main ( S t r i n g [ ] a r g s ) Random randgen = new Random ( ) ; i n t randomang = randgen. n e x t I n t ( ) ; System. o u t. p r i n t l n ( randomang ) ; Exercise 1-5 Supermarket Change Write a Java program CountChange to count change. Given the number of quarter, dimes, nickles, and pennies the program should output the total as a single value in dollars and pennies. Hint: One dollar corresponds to 100 pennies. One quarter corresponds to 25 pennies. One dime corresponds to 10 pennies. One nickle corresponds to 5 pennies. 4

5 For example if we have: 3 quarters, 2 dimes, 1 nickle and 6 pennies, then the total is 1.06 dollars. p u b l i c c l a s s CountChange p u b l i c s t a t i c void main ( S t r i n g [ ] a r g s ) i n t q u a r t e r s, dimes, n i c k l e s, p e n n i e s ; q u a r t e r s = 3 ; dimes = 2 ; n i c k l e s = 1 ; p e n n i e s = 6 ; double t o t a l = q u a r t e r s 25 + dimes 10 + n i c k l e s 5 + p e n n i e s ; System. o u t. p r i n t l n ( " T o t a l i s : $ " + t o t a l / ) ; Exercise 1-6 Cook in a Hurry You want to cook some pasta, but you are short of time. To be sure you can finish cooking before your next appointment, you need to know how long it takes for the water to boil. At its highest setting, your stove needs two minutes per liter (1l = 1 1,000 m3 ) to reach the boiling point. You use a cylindric pot. Write a program that, given the diameter of the pot and the hight of the water in it, calculates the the time needed for the water to boil. Hint. The Volume of a cilinder is π r 2 h. p u b l i c c l a s s CookSomePasta p u b l i c s t a t i c void main ( S t r i n g [ ] a r g s ) f i n a l double PI = ; double d i a m e t e r = 7. 0 ; double h e i g h t = 6. 0 ; double r a d i u s = d i a m e t e r / 2 ; / / c a l c u l a t e t h e volume double volume = PI r a d i u s r a d i u s h e i g h t ; / / Assume t h a t d i a m e t e r & h e i g h t are g i v e n i n c e n t i m e t e r s double l i t e r s = volume / 1000; / / The s t o v e needs two m i n u t e s per l i t e r double time = l i t e r s 2 ; System. o u t. p r i n t ( " Stove needs " + time + " m i n u t e s. " ) ; import j a v a. u t i l. ; p u b l i c c l a s s CookSomePasta p u b l i c s t a t i c void main ( S t r i n g [ ] a r g s ) f i n a l double PI = ; Scanner sc = new Scanner ( System. i n ) ; System. o u t. p r i n t ( " E n t e r d i a m e t e r : " ) ; double d i a m e t e r = sc. nextdouble ( ) ; 5

6 System. o u t. p r i n t ( " E n t e r h e i g h t : " ) ; double h e i g h t = sc. nextdouble ( ) ; double r a d i u s = d i a m e t e r / 2 ; / / c a l c u l a t e t h e volume double volume = PI r a d i u s r a d i u s h e i g h t ; / / Assume t h a t d i a m e t e r & h e i g h t are g i v e n i n c e n t i m e t e r s double l i t e r s = volume / 1000; / / The s t o v e needs two m i n u t e s per l i t e r double time = l i t e r s 2 ; System. o u t. p r i n t ( " Stove needs " + time + " m i n u t e s. " ) ; Exercise 1-7 Electrical Resistance The equivalent resistance of resistors connected in series is calculated by adding the resistances of the individual resistors. The formula for resistors connected in parallel is a little more complex. Given two resistors with resistances R1 and R2 connected in parallel the equivalent resistance is given by the inverse of the sum of the inverses; e.g. 1 Req = 1 R1 + 1 R2. Write a program that given 3 resistances outputs the equivalent resistance when they are connected in series and when they are connected in parallel. p u b l i c c l a s s R e s i s t a n c e p u b l i c s t a t i c void main ( S t r i n g [ ] a r g s ) throws IOException f l o a t r1 = 8, r2 = 8, r3 = 4 ; f l o a t r e s S = r1 + r2 + r3 ; f l o a t r e s P I n v = 1 / r1 + 1 / r2 + 1 / r3 ; f l o a t r e s P = 1 / r e s P I n v ; System. o u t. p r i n t l n ( " S e r i e s r e s i s t a n c e : " + r e s S ) ; System. o u t. p r i n t l n ( " P a r a l l e l r e s i s t a n c e : " + r e s P ) ; Exercise 1-8 Temperature Conversion Assume that you have a Celsius scale temperature of 100 degrees and you wish to convert it into degrees on the Fahrenheit scale and the Kelvin scale. This conversion is done using the following formulas. T f = 9 5 T c + 32, and T k = T c Where T f is temperature in degrees Fahrenheit, T c is temperature in degrees Celsius, and T k is temperature in degrees Kelvin. 6

7 Write a Java program that takes as an input a degree in Celsius scale and converts it into both Fahrenheit and Kelvin scales. import j a v a. u t i l. ; p u b l i c c l a s s T e m p e r a t u r e C a l c u l a t o r p u b l i c s t a t i c void main ( S t r i n g [ ] a r g s ) Scanner sc = new Scanner ( System. i n ) ; double c e l s i u s, f a h r e n h e i t, k e l v i n ; System. o u t. p r i n t ( " P l e a s e i n s e r t t h e t e m p e r a t u r e i n d e g r e e s C e l s i u s " ) ; c e l s i u s = sc. nextdouble ( ) ; f a h r e n h e i t = ( 9. 0 / 5 c e l s i u s ) ; k e l v i n = c e l s i u s ; System. o u t. p r i n t l n ( " Temperature i n d e g r e e s F a h r e n h e i t i s " + f a h r e n h e i t ) ; System. o u t. p r i n t l n ( " Temperature i n d e g r e e s Kelvin i s " + k e l v i n ) ; Exercise 1-9 Octal Conversion To be discussed in the Tutorial Assume that you have an octal number (base 8) and you would like to convert it into its equivalent decimal number (base 10) and binary number (base 2). For example: (27) 8 is equal to (23) 10 in decimal and (10111) 2 in binary. Write a sequential Java program to convert a two digit octal number into its equivalent binary and decimal numbers. import j a v a. u t i l. ; p u b l i c c l a s s O c t a l p u b l i c s t a t i c void main ( S t r i n g [ ] a r g s ) i n t oct0, o c t 1 ; i n t q0, q1, q2, r0, r1, r2 ; Scanner sc = new Scanner ( System. i n ) ; System. o u t. p r i n t ( " P l e a s e e n t e r t h e o c t a l number : " ) ; i n t o c t a l = sc. n e x t I n t ( ) ; / / e x t r a c t i n g t h e d i g i t s o c t 0 = o c t a l %10; o c t 1 = o c t a l / 1 0 ; / / C a l c u l a t e t h e d e c i m a l Value double dec = o c t o c t 1 8 ; i n t r e s u l t = ( i n t ) dec ; System. o u t. p r i n t l n ( o c t a l + " i n o c t a l = " + r e s u l t + " i n d e c i m a l. " ) ; / / c o n v e r t i n g t h e f i r s t d i g i t base 8 i n t o 3 b i t s q0 = o c t 1 / 2 ; r0 = o c t 1 %2; q1 = q0 / 2 ; r1 = q0%2; q2 = q1 / 2 ; r2 = q1%2; 7

8 System. o u t. p r i n t ( o c t a l + " i n o c t a l = "+ r2 +" "+ r1 +" "+ r0 +" " ) ; / / c o n v e r t i n g t h e second d i g i t base 8 i n t o 3 b i t s q0 = o c t 0 / 2 ; r0 = o c t 0 %2; q1 = q0 / 2 ; r1 = q0%2; q2 = q1 / 2 ; r2 = q1%2; System. o u t. p r i n t l n ( r2 +" "+ r1 +" "+ r0 +" i n b i n a r y. " ) ; 8

Introduction to Computer Programming, Spring Term 2018 Practice Assignment 1 Discussion:

Introduction to Computer Programming, Spring Term 2018 Practice Assignment 1 Discussion: German University in Cairo Media Engineering and Technology Prof. Dr. Slim Abdennadher Dr. Rimon Elias Dr. Hisham Othman Introduction to Computer Programming, Spring Term 2018 Practice Assignment 1 Discussion:

More information

Introduction to Computer Programming, Spring Term 2018 Practice Assignment 5 Discussion: power(m,n) = m n

Introduction to Computer Programming, Spring Term 2018 Practice Assignment 5 Discussion: power(m,n) = m n German University in Cairo Media Engineering and Technology Prof. Dr. Slim Abdennadher Dr. Mohammed Abdel Megeed Introduction to Computer Programming, Spring Term 2018 Practice Assignment 5 Discussion:

More information

CSEN102 Introduction to Computer Science

CSEN102 Introduction to Computer Science CSEN102 Introduction to Computer Science Lecture 7: Representing Information I Prof. Dr. Slim Abdennadher Dr. Mohammed Salem, slim.abdennadher@guc.edu.eg, mohammed.salem@guc.edu.eg German University Cairo,

More information

Introduction to Computer Programming, Spring Term 2018 Practice Assignment 3 Discussion:

Introduction to Computer Programming, Spring Term 2018 Practice Assignment 3 Discussion: German University in Cairo Media Engineering and Technology Prof. Dr. Slim Abdennadher Dr. Mohammed Abdel Megeed Introduction to Computer Programming, Spring Term 2018 Practice Assignment 3 Discussion:

More information

1. Write a program to calculate distance traveled by light

1. Write a program to calculate distance traveled by light G. H. R a i s o n i C o l l e g e O f E n g i n e e r i n g D i g d o h H i l l s, H i n g n a R o a d, N a g p u r D e p a r t m e n t O f C o m p u t e r S c i e n c e & E n g g P r a c t i c a l M a

More information

TI-36X Solar, English

TI-36X Solar, English TI-36X Solar, English www.ti.com/calc ti-cares@ti.com TI.36X SOLAR Scientific Calculator Basic Operations... 2 Results... 2 Basic Arithmetic... 3 Percents... 4 Fractions... 5 Powers and Roots... 6 Logarithmic

More information

CS Exam 1 Study Guide and Practice Exam

CS Exam 1 Study Guide and Practice Exam CS 150 - Exam 1 Study Guide and Practice Exam September 11, 2017 Summary 1 Disclaimer 2 Variables 2.1 Primitive Types.............................................. 2.2 Suggestions, Warnings, and Resources.................................

More information

CHEM 103 Measurement in Chemistry

CHEM 103 Measurement in Chemistry CHEM 103 Measurement in Chemistry Lecture Notes January 26, 2006 Prof. Sevian 1 Agenda Calculations skills you need: Dimensional analysis Significant figures Scientific notation Group problem #1 2 2005

More information

1 Computing System 2. 2 Data Representation Number Systems 22

1 Computing System 2. 2 Data Representation Number Systems 22 Chapter 4: Computing System & Data Representation Christian Jacob 1 Computing System 2 1.1 Abacus 3 2 Data Representation 19 3 Number Systems 22 3.1 Important Number Systems for Computers 24 3.2 Decimal

More information

MATH Dr. Halimah Alshehri Dr. Halimah Alshehri

MATH Dr. Halimah Alshehri Dr. Halimah Alshehri MATH 1101 haalshehri@ksu.edu.sa 1 Introduction To Number Systems First Section: Binary System Second Section: Octal Number System Third Section: Hexadecimal System 2 Binary System 3 Binary System The binary

More information

Data Structures and Algorithms Winter Semester

Data Structures and Algorithms Winter Semester Page 0 German University in Cairo December 26, 2015 Media Engineering and Technology Faculty Prof. Dr. Slim Abdennadher Dr. Wael Abouelsadaat Data Structures and Algorithms Winter Semester 2015-2016 Final

More information

Numbering Systems. Contents: Binary & Decimal. Converting From: B D, D B. Arithmetic operation on Binary.

Numbering Systems. Contents: Binary & Decimal. Converting From: B D, D B. Arithmetic operation on Binary. Numbering Systems Contents: Binary & Decimal. Converting From: B D, D B. Arithmetic operation on Binary. Addition & Subtraction using Octal & Hexadecimal 2 s Complement, Subtraction Using 2 s Complement.

More information

Announcements. CompSci 102 Discrete Math for Computer Science. Chap. 3.1 Algorithms. Specifying Algorithms

Announcements. CompSci 102 Discrete Math for Computer Science. Chap. 3.1 Algorithms. Specifying Algorithms CompSci 102 Discrete Math for Computer Science Announcements Read for next time Chap. 3.1-3.3 Homework 3 due Tuesday We ll finish Chapter 2 first today February 7, 2012 Prof. Rodger Chap. 3.1 Algorithms

More information

Problem Points Score Total 100

Problem Points Score Total 100 Exam 1 A. Miller Spring 2005 Math 240 1 Show all work. No notes, no books, no calculators, no cell phones, no pagers, no electronic devices of any kind. Name Circle your Discussion Section: DIS 303 12:05p

More information

Problem Points Score Total 100

Problem Points Score Total 100 Final Exam A. Miller Spring 2005 Math 240 0 Show all work. No books, no calculators, no cell phones, no pagers, no electronic devices of any kind. However you can bring to the exam one 8.5 by 11 cheat

More information

CSEN202: Introduction to Computer Programming Spring Semester 2014 Final Exam

CSEN202: Introduction to Computer Programming Spring Semester 2014 Final Exam Page 0 German University in Cairo June 14, 2014 Media Engineering and Technology Faculty Prof. Dr. Slim Abdennadher CSEN202: Introduction to Computer Programming Spring Semester 2014 Final Exam Bar Code

More information

CS 163/164 - Exam 1 Study Guide and Practice Exam

CS 163/164 - Exam 1 Study Guide and Practice Exam CS 163/164 - Exam 1 Study Guide and Practice Exam September 11, 2017 Summary 1 Disclaimer 2 Variables 2.1 Primitive Types.............................................. 2.2 Strings...................................................

More information

Counting Methods. CSE 191, Class Note 05: Counting Methods Computer Sci & Eng Dept SUNY Buffalo

Counting Methods. CSE 191, Class Note 05: Counting Methods Computer Sci & Eng Dept SUNY Buffalo Counting Methods CSE 191, Class Note 05: Counting Methods Computer Sci & Eng Dept SUNY Buffalo c Xin He (University at Buffalo) CSE 191 Discrete Structures 1 / 48 Need for Counting The problem of counting

More information

Computer Science Introductory Course MSc - Introduction to Java

Computer Science Introductory Course MSc - Introduction to Java Computer Science Introductory Course MSc - Introduction to Java Lecture 1: Diving into java Pablo Oliveira ENST Outline 1 Introduction 2 Primitive types 3 Operators 4 5 Control Flow

More information

Introduction to Language Theory and Compilation: Exercises. Session 2: Regular expressions

Introduction to Language Theory and Compilation: Exercises. Session 2: Regular expressions Introduction to Language Theory and Compilation: Exercises Session 2: Regular expressions Regular expressions (RE) Finite automata are an equivalent formalism to regular languages (for each regular language,

More information

At the end of the exam you must copy that folder onto a USB stick. Also, you must your files to the instructor.

At the end of the exam you must copy that folder onto a USB stick. Also, you must  your files to the instructor. Before you begin your work, please create a new file folder on your computer. The name of the folder should be YourLastName_YourFirstName For example, if your name is John Smith your folder should be named

More information

ECEN 651: Microprogrammed Control of Digital Systems Department of Electrical and Computer Engineering Texas A&M University

ECEN 651: Microprogrammed Control of Digital Systems Department of Electrical and Computer Engineering Texas A&M University ECEN 651: Microprogrammed Control of Digital Systems Department of Electrical and Computer Engineering Texas A&M University Prof. Mi Lu TA: Ehsan Rohani Laboratory Exercise #4 MIPS Assembly and Simulation

More information

b) Write the contrapositive of this given statement: If I finish ALEKS, then I get points.

b) Write the contrapositive of this given statement: If I finish ALEKS, then I get points. Math 141 Name: QUIZ 1A (CHAPTER 0: PRELIMINARY TOPICS) MATH 141 SPRING 2019 KUNIYUKI 90 POINTS TOTAL No notes or books allowed. A scientific calculator is allowed. Simplify as appropriate. Check one: Can

More information

Math 463/563 Homework #2 - Solutions

Math 463/563 Homework #2 - Solutions Math 463/563 Homework #2 - Solutions 1. How many 5-digit numbers can be formed with the integers 1, 2,..., 9 if no digit can appear exactly once? (For instance 43443 is OK, while 43413 is not allowed.)

More information

Informatics 1 - Computation & Logic: Tutorial 3

Informatics 1 - Computation & Logic: Tutorial 3 Informatics 1 - Computation & Logic: Tutorial 3 Counting Week 5: 16-20 October 2016 Please attempt the entire worksheet in advance of the tutorial, and bring all work with you. Tutorials cannot function

More information

MATH 243E Test #3 Solutions

MATH 243E Test #3 Solutions MATH 4E Test # Solutions () Find a recurrence relation for the number of bit strings of length n that contain a pair of consecutive 0s. You do not need to solve this recurrence relation. (Hint: Consider

More information

import java. u t i l. ;... Scanner sc = new Scanner ( System. in ) ;

import java. u t i l. ;... Scanner sc = new Scanner ( System. in ) ; CPSC 490 Input Input will always arrive on stdin. You may assume input is well-formed with respect to the problem specification; inappropriate input (e.g. text where a number was specified, number out

More information

HEC-HMS Lab 4 Using Frequency Storms in HEC-HMS

HEC-HMS Lab 4 Using Frequency Storms in HEC-HMS HEC-HMS Lab 4 Using Frequency Storms in HEC-HMS Created by Venkatesh Merwade (vmerwade@purdue.edu) Learning outcomes The objective of this lab is to learn how HEC-HMS is used to determine design flow by

More information

Binary addition example worked out

Binary addition example worked out Binary addition example worked out Some terms are given here Exercise: what are these numbers equivalent to in decimal? The initial carry in is implicitly 0 1 1 1 0 (Carries) 1 0 1 1 (Augend) + 1 1 1 0

More information

COMP 120. For any doubts in the following, contact Agam, Room. 023

COMP 120. For any doubts in the following, contact Agam, Room. 023 COMP 120 Computer Organization Spring 2006 For any doubts in the following, contact Agam, Room. 023 Problem Set #1 Solution Problem 1. Miss Information [A] First card ca n be any one of 52 possibilities.

More information

Assignment 1: Due Friday Feb 6 at 6pm

Assignment 1: Due Friday Feb 6 at 6pm CS1110 Spring 2015 Assignment 1: Due Friday Feb 6 at 6pm You must work either on your own or with one partner. If you work with a partner, you and your partner must first register as a group in CMS and

More information

Chapter 5 Measurements and Calculations Objectives

Chapter 5 Measurements and Calculations Objectives Objectives 1. To show how very large or very small numbers can be expressed in scientific notation 2. To learn the English, metric, and SI systems of measurement 3. To use the metric system to measure

More information

Comp 11 Lectures. Mike Shah. July 26, Tufts University. Mike Shah (Tufts University) Comp 11 Lectures July 26, / 40

Comp 11 Lectures. Mike Shah. July 26, Tufts University. Mike Shah (Tufts University) Comp 11 Lectures July 26, / 40 Comp 11 Lectures Mike Shah Tufts University July 26, 2017 Mike Shah (Tufts University) Comp 11 Lectures July 26, 2017 1 / 40 Please do not distribute or host these slides without prior permission. Mike

More information

ENGIN 112 Intro to Electrical and Computer Engineering

ENGIN 112 Intro to Electrical and Computer Engineering ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems Overview Hexadecimal numbers Related to binary and octal numbers Conversion between hexadecimal, octal and binary Value

More information

The trial run demonstrates that the program runs and produces correct results in a test case.

The trial run demonstrates that the program runs and produces correct results in a test case. 42 1 Computing with Formulas the exercise. The second phase is to write the program. The more efforts you put into the first phase, the easier it will be to find the right statements and write the code.

More information

Prelaboratory. EE223 Laboratory #1 Digital to Analog Converter

Prelaboratory. EE223 Laboratory #1 Digital to Analog Converter EE223 Laboratory #1 Digital to Analog Converter Objectives: 1) Learn how superposition and Thevenin conversions are used to analyze practical circuits 2) Become familiar with ground bus and power bus notation

More information

Assignment 4: Object creation

Assignment 4: Object creation Assignment 4: Object creation ETH Zurich Hand-out: 13 November 2006 Due: 21 November 2006 Copyright FarWorks, Inc. Gary Larson 1 Summary Today you are going to create a stand-alone program. How to create

More information

Adding and Subtracting Polynomials

Adding and Subtracting Polynomials 7.2 Adding and Subtracting Polynomials subtract polynomials? How can you add polynomials? How can you 1 EXAMPLE: Adding Polynomials Using Algebra Tiles Work with a partner. Six different algebra tiles

More information

Section 5.1 Scientific Notation and Units Objectives

Section 5.1 Scientific Notation and Units Objectives Objectives 1. To show how very large or very small numbers can be expressed in scientific notation 2. To learn the English, metric, and SI systems of measurement 3. To use the metric system to measure

More information

FACULTY OF SCIENCE ACADEMY OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING OBJECT ORIENTED PROGRAMMING DATE 07/2014 SESSION 8:00-10:00

FACULTY OF SCIENCE ACADEMY OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING OBJECT ORIENTED PROGRAMMING DATE 07/2014 SESSION 8:00-10:00 FACULTY OF SCIENCE ACADEMY OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING MODULE CAMPUS CSC2A10 OBJECT ORIENTED PROGRAMMING AUCKLAND PARK CAMPUS (APK) EXAM JULY 2014 DATE 07/2014 SESSION 8:00-10:00 ASSESOR(S)

More information

You separate binary numbers into columns in a similar fashion. 2 5 = 32

You separate binary numbers into columns in a similar fashion. 2 5 = 32 RSA Encryption 2 At the end of Part I of this article, we stated that RSA encryption works because it s impractical to factor n, which determines P 1 and P 2, which determines our private key, d, which

More information

Introduction to Python and its unit testing framework

Introduction to Python and its unit testing framework Introduction to Python and its unit testing framework Instructions These are self evaluation exercises. If you know no python then work through these exercises and it will prepare yourself for the lab.

More information

Number Theory: Representations of Integers

Number Theory: Representations of Integers Instructions: In-class exercises are meant to introduce you to a new topic and provide some practice with the new topic. Work in a team of up to 4 people to complete this exercise. You can work simultaneously

More information

Some. AWESOME Great Theoretical Ideas in Computer Science about Generating Functions Probability

Some. AWESOME Great Theoretical Ideas in Computer Science about Generating Functions Probability 15-251 Some AWESOME Great Theoretical Ideas in Computer Science about Generating Functions Probability 15-251 Some AWESOME Great Theoretical Ideas in Computer Science about Generating Functions Infinity

More information

Hybrid Activity: Measuring with Metric. Introduction: Standard Metric Units. Names

Hybrid Activity: Measuring with Metric. Introduction: Standard Metric Units. Names Hybrid Activity: Measuring with Metric Names Date Period Introduction: The purpose of this activity is to practice using the metric system. To conduct a scientific investigation, a researcher must be able

More information

CISC 1400 Discrete Structures

CISC 1400 Discrete Structures CISC 1400 Discrete Structures Chapter 2 Sequences What is Sequence? A sequence is an ordered list of objects or elements. For example, 1, 2, 3, 4, 5, 6, 7, 8 Each object/element is called a term. 1 st

More information

ECE 204 Numerical Methods for Computer Engineers MIDTERM EXAMINATION /8:00-9:30

ECE 204 Numerical Methods for Computer Engineers MIDTERM EXAMINATION /8:00-9:30 ECE 204 Numerical Methods for Computer Engineers MIDTERM EXAMINATION 2007-10-23/8:00-9:30 The examination is out of 67 marks. Instructions: No aides. Write your name and student ID number on each booklet.

More information

Arithmetic and Geometric Progressions

Arithmetic and Geometric Progressions GEOL 595 - Mathematical Tools in Geology Lab Assignment # 5 - Sept 30, 2008 (Due Oct 8) Name: Arithmetic and Geometric Progressions A. Arithmetic Progressions 1. We learned in class that a sequence of

More information

Finding a Percent of a Number (page 216)

Finding a Percent of a Number (page 216) LESSON Name 1 Finding a Percent of a Number (page 216) You already know how to change a percent to a fraction. Rewrite the percent as a fraction with a denominator of 100 and reduce. 25% = 25 100 = 1 5%

More information

CS1800 Discrete Structures Spring 2018 February CS1800 Discrete Structures Midterm Version A

CS1800 Discrete Structures Spring 2018 February CS1800 Discrete Structures Midterm Version A CS1800 Discrete Structures Spring 2018 February 2018 CS1800 Discrete Structures Midterm Version A Instructions: 1. The exam is closed book and closed notes. You may not use a calculator or any other electronic

More information

Chapter 1. Introduction: Matter and Measurement. Chemistry. In this science we study matter, its properties, and its behavior. Matter And Measurement

Chapter 1. Introduction: Matter and Measurement. Chemistry. In this science we study matter, its properties, and its behavior. Matter And Measurement Chapter 1 Introduction: and Chemistry 2 In this science we study matter, its properties, and its behavior. We define matter as anything that has mass and takes up space. 3 4 Atoms are the building blocks

More information

ITI Introduction to Computing II

ITI Introduction to Computing II (with contributions from R. Holte) School of Electrical Engineering and Computer Science University of Ottawa Version of January 11, 2015 Please don t print these lecture notes unless you really need to!

More information

University of Florida EEL 3701 Fall 2014 Dr. Eric. M. Schwartz Department of Electrical & Computer Engineering Wednesday, 15 October 2014

University of Florida EEL 3701 Fall 2014 Dr. Eric. M. Schwartz Department of Electrical & Computer Engineering Wednesday, 15 October 2014 Page 1/12 Exam 1 May the Schwartz Instructions: be with you! Turn off all cell phones and other noise making devices and put away all electronics Show all work on the front of the test papers Box each

More information

MiniMat: Matrix Language in OCaml LLVM

MiniMat: Matrix Language in OCaml LLVM Terence Lim - tl2735@columbia.edu August 17, 2016 Contents 1 Introduction 4 1.1 Goals........................................ 4 1.1.1 Flexible matrix notation......................... 4 1.1.2 Uncluttered................................

More information

Programming Assignment 4: Image Completion using Mixture of Bernoullis

Programming Assignment 4: Image Completion using Mixture of Bernoullis Programming Assignment 4: Image Completion using Mixture of Bernoullis Deadline: Tuesday, April 4, at 11:59pm TA: Renie Liao (csc321ta@cs.toronto.edu) Submission: You must submit two files through MarkUs

More information

Chapter 1 An Introduction to Chemistry

Chapter 1 An Introduction to Chemistry 1 Chapter 1 An Introduction to Chemistry 1.1 What Is Chemistry, and What Can Chemistry Do for You? Special Topic 1.1: Green Chemistry 1.2 Suggestions for Studying Chemistry 1.3 The Scientific Method 1.4

More information

UNIVERSITI TENAGA NASIONAL. College of Information Technology

UNIVERSITI TENAGA NASIONAL. College of Information Technology UNIVERSITI TENAGA NASIONAL College of Information Technology BACHELOR OF COMPUTER SCIENCE (HONS.) FINAL EXAMINATION SEMESTER 2 2012/2013 DIGITAL SYSTEMS DESIGN (CSNB163) January 2013 Time allowed: 3 hours

More information

Lab Exercise 6 CS 2334

Lab Exercise 6 CS 2334 Lab Exercise 6 CS 2334 September 28, 2017 Introduction In this lab, you will experiment with using inheritance in Java through the use of abstract classes and interfaces. You will implement a set of classes

More information

I: INTRODUCTION. 1.1 Using the Text in a Lecture Course

I: INTRODUCTION. 1.1 Using the Text in a Lecture Course I: INTRODUCTION The text, Fundamentals of Logic Design,7th edition, has been designed so that it can be used either for a standard lecture course or for a self-paced course. The text is divided into 20

More information

Student Outcomes. Lesson Notes. Classwork. Opening Exercises 1 3 (5 minutes)

Student Outcomes. Lesson Notes. Classwork. Opening Exercises 1 3 (5 minutes) Student Outcomes Students calculate the decimal expansion of using basic properties of area. Students estimate the value of expressions such as. Lesson Notes For this lesson, students will need grid paper

More information

Page Points Score Total: 100

Page Points Score Total: 100 Math 1130 Spring 2019 Sample Exam 1c 1/31/19 Name (Print): Username.#: Lecturer: Rec. Instructor: Rec. Time: This exam contains 8 pages (including this cover page) and 7 problems. Check to see if any pages

More information

Four Important Number Systems

Four Important Number Systems Four Important Number Systems System Why? Remarks Decimal Base 10: (10 fingers) Most used system Binary Base 2: On/Off systems 3-4 times more digits than decimal Octal Base 8: Shorthand notation for working

More information

Digital Systems Overview. Unit 1 Numbering Systems. Why Digital Systems? Levels of Design Abstraction. Dissecting Decimal Numbers

Digital Systems Overview. Unit 1 Numbering Systems. Why Digital Systems? Levels of Design Abstraction. Dissecting Decimal Numbers Unit Numbering Systems Fundamentals of Logic Design EE2369 Prof. Eric MacDonald Fall Semester 2003 Digital Systems Overview Digital Systems are Home PC XBOX or Playstation2 Cell phone Network router Data

More information

What Every Programmer Should Know About Floating-Point Arithmetic DRAFT. Last updated: November 3, Abstract

What Every Programmer Should Know About Floating-Point Arithmetic DRAFT. Last updated: November 3, Abstract What Every Programmer Should Know About Floating-Point Arithmetic Last updated: November 3, 2014 Abstract The article provides simple answers to the common recurring questions of novice programmers about

More information

In this lecture, we will consider how to analyse an electrical circuit by applying KVL and KCL. As a result, we can predict the voltages and currents

In this lecture, we will consider how to analyse an electrical circuit by applying KVL and KCL. As a result, we can predict the voltages and currents In this lecture, we will consider how to analyse an electrical circuit by applying KVL and KCL. As a result, we can predict the voltages and currents around an electrical circuit. This is a short lecture,

More information

Chapter 2 (Part 3): The Fundamentals: Algorithms, the Integers & Matrices. Integers & Algorithms (2.5)

Chapter 2 (Part 3): The Fundamentals: Algorithms, the Integers & Matrices. Integers & Algorithms (2.5) CSE 54 Discrete Mathematics & Chapter 2 (Part 3): The Fundamentals: Algorithms, the Integers & Matrices Integers & Algorithms (Section 2.5) by Kenneth H. Rosen, Discrete Mathematics & its Applications,

More information

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Catie Baker Spring 2015

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Catie Baker Spring 2015 CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Catie Baker Spring 2015 Today Registration should be done. Homework 1 due 11:59pm next Wednesday, April 8 th. Review math

More information

14:332:231 DIGITAL LOGIC DESIGN. Why Binary Number System?

14:332:231 DIGITAL LOGIC DESIGN. Why Binary Number System? :33:3 DIGITAL LOGIC DESIGN Ivan Marsic, Rutgers University Electrical & Computer Engineering Fall 3 Lecture #: Binary Number System Complement Number Representation X Y Why Binary Number System? Because

More information

Measurement & Lab Equipment

Measurement & Lab Equipment Measurement & Lab Equipment Abstract This lab reviews the concept of scientific measurement, which you will employ weekly throughout this course. Specifically, we will review the metric system so that

More information

Name: Exam 2 Solutions. March 13, 2017

Name: Exam 2 Solutions. March 13, 2017 Department of Mathematics University of Notre Dame Math 00 Finite Math Spring 07 Name: Instructors: Conant/Galvin Exam Solutions March, 07 This exam is in two parts on pages and contains problems worth

More information

CHAPTER TWO: MEASUREMENTS AND PROBLEM SOLVING

CHAPTER TWO: MEASUREMENTS AND PROBLEM SOLVING CHAPTER TWO: MEASUREMENTS AND PROBLEM SOLVING Measurements: Our Starting Point! Why should we begin our study of chemistry with the topic of measurement?! Much of the laboratory work in this course is

More information

4. What is the probability that the two values differ by 4 or more in absolute value? There are only six

4. What is the probability that the two values differ by 4 or more in absolute value? There are only six 1. Short Questions: 2/2/2/2/2 Provide a clear and concise justification of your answer. In this problem, you roll two balanced six-sided dice. Hint: Draw a picture. 1. What is the probability that the

More information

LAMC Intermediate I & II October 12, Oleg Gleizer. Warm-up

LAMC Intermediate I & II October 12, Oleg Gleizer. Warm-up LAMC Intermediate I & II October 2, 204 Oleg Gleizer prof40g@math.ucla.edu Warm-up Problem A student was asked to divide some number by two and to add three to the result. By mistake, the student multiplied

More information

Scientific Notation. exploration. 1. Complete the table of values for the powers of ten M8N1.j. 110 Holt Mathematics

Scientific Notation. exploration. 1. Complete the table of values for the powers of ten M8N1.j. 110 Holt Mathematics exploration Georgia Performance Standards M8N1.j 1. Complete the table of values for the powers of ten. Exponent 6 10 6 5 10 5 4 10 4 Power 3 10 3 2 10 2 1 1 0 2 1 0.01 10 10 1 10 1 1 1 0 1 1 0.1 10 0

More information

MATH 407 FINAL EXAM May 6, 2011 Prof. Alexander

MATH 407 FINAL EXAM May 6, 2011 Prof. Alexander MATH 407 FINAL EXAM May 6, 2011 Prof. Alexander Problem Points Score 1 22 2 18 Last Name: First Name: USC ID: Signature: 3 20 4 21 5 27 6 18 7 25 8 28 Total 175 Points total 179 but 175 is maximum. This

More information

MODULE 1: MATH BASICS

MODULE 1: MATH BASICS MATH FUNDAMENTALS MODULE 1: MATH BASICS In the medical world, the most beneficial drug can be rendered worthless or dangerous if the veterinarian or animal health technician does not accurately calculate

More information

the distance from the top to the bottom of an object height a measurement of how heavy something is weight

the distance from the top to the bottom of an object height a measurement of how heavy something is weight height the distance from the top to the bottom of an object weight a measurement of how heavy something is length the distance from one side of an object to another measure to find the number that shows

More information

Compiling Techniques

Compiling Techniques Lecture 3: Introduction to 22 September 2017 Reminder Action Create an account and subscribe to the course on piazza. Coursework Starts this afternoon (14.10-16.00) Coursework description is updated regularly;

More information

On my honor, as an Aggie, I have neither given nor received unauthorized aid on this academic work

On my honor, as an Aggie, I have neither given nor received unauthorized aid on this academic work Lab 5 : Linking Name: Sign the following statement: On my honor, as an Aggie, I have neither given nor received unauthorized aid on this academic work 1 Objective The main objective of this lab is to experiment

More information

ME 105 Mechanical Engineering Laboratory Spring Quarter Experiment #2: Temperature Measurements and Transient Conduction and Convection

ME 105 Mechanical Engineering Laboratory Spring Quarter Experiment #2: Temperature Measurements and Transient Conduction and Convection ME 105 Mechanical Engineering Lab Page 1 ME 105 Mechanical Engineering Laboratory Spring Quarter 2010 Experiment #2: Temperature Measurements and Transient Conduction and Convection Objectives a) To calibrate

More information

The problems in this booklet are organized into strands. A problem often appears in multiple strands. The problems are suitable for most students in

The problems in this booklet are organized into strands. A problem often appears in multiple strands. The problems are suitable for most students in The problems in this booklet are organized into strands. A problem often appears in multiple strands. The problems are suitable for most students in Grade 7 or higher. Problem C A Time For Change A customer

More information

Number Representation and Waveform Quantization

Number Representation and Waveform Quantization 1 Number Representation and Waveform Quantization 1 Introduction This lab presents two important concepts for working with digital signals. The first section discusses how numbers are stored in memory.

More information

Lesson Title PA Common Core CCSS Numbers and Counting. Instruction Lesson Day Routines CC A.3 2.MD.8

Lesson Title PA Common Core CCSS Numbers and Counting. Instruction Lesson Day Routines CC A.3 2.MD.8 Second Grade Scope and Sequence 2016-2017 Numbers and Counting Lesson 1.1 1 Day Routines CC.2.4.2.A.3 2.MD.8 Lesson 1.2 1 Day Counting on a Number Line CC.2.4.2.A.6, CC.2.1.2.B.2 2.MD.6, 2.NBT.2 Lesson

More information

CS1800 Discrete Structures Final Version A

CS1800 Discrete Structures Final Version A CS1800 Discrete Structures Fall 2017 Profs. Aslam, Gold, & Pavlu December 11, 2017 CS1800 Discrete Structures Final Version A Instructions: 1. The exam is closed book and closed notes. You may not use

More information

An analogy from Calculus: limits

An analogy from Calculus: limits COMP 250 Fall 2018 35 - big O Nov. 30, 2018 We have seen several algorithms in the course, and we have loosely characterized their runtimes in terms of the size n of the input. We say that the algorithm

More information

Science 350 Week 1 Module 1 Schedule

Science 350 Week 1 Module 1 Schedule Science 350 Week 1 Module 1 Schedule Date: Day 1 1 Day 2 2 Day 3 3 Day 4 4 Day 5 5 pp. 1 7 (top) pp. 7 13 ( Manipulating Units through pp. 13 19 ( More Complex through pp. 19 25 ( Making Measurements through

More information

Data Structure and Algorithm Homework #1 Due: 2:20pm, Tuesday, March 12, 2013 TA === Homework submission instructions ===

Data Structure and Algorithm Homework #1 Due: 2:20pm, Tuesday, March 12, 2013 TA   === Homework submission instructions === Data Structure and Algorithm Homework #1 Due: 2:20pm, Tuesday, March 12, 2013 TA email: dsa1@csie.ntu.edu.tw === Homework submission instructions === For Problem 1, submit your source code, a Makefile

More information

STAT2201 Assignment 1 Semester 1, 2018 Due 16/3/2018

STAT2201 Assignment 1 Semester 1, 2018 Due 16/3/2018 Class Example 1. Hello World in Julia The purpose of this exercise is to gain familiarity with the Julia interface. (a) Log into JuliaBox. (b) Solve 1+1 in Julia. (c) Now let s explore this simple thing:

More information

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata CISC 4090: Theory of Computation Chapter Regular Languages Xiaolan Zhang, adapted from slides by Prof. Werschulz Section.: Finite Automata Fordham University Department of Computer and Information Sciences

More information

Temperature and Speed Conversions

Temperature and Speed Conversions Temperature and Speed Conversions Many people are familiar with the U.S. Customary units of measure, either because they are using them now or have used them in the past. However, the metric system, while

More information

Page Points Score Total: 100

Page Points Score Total: 100 Math 1130 Spring 2019 Sample Midterm 3c 4/11/19 Name (Print): Username.#: Lecturer: Rec. Instructor: Rec. Time: This exam contains 10 pages (including this cover page) and 10 problems. Check to see if

More information

Scientific Method: a logical approach to understanding or solving problems that needs solved.

Scientific Method: a logical approach to understanding or solving problems that needs solved. Chapter 2 Section 1 Section 2-1 Objectives Describe the purpose of the scientific method. Distinguish between qualitative and quantitative observations. Describe the differences between hypotheses, theories,

More information

Measuring Goodness of an Algorithm. Asymptotic Analysis of Algorithms. Measuring Efficiency of an Algorithm. Algorithm and Data Structure

Measuring Goodness of an Algorithm. Asymptotic Analysis of Algorithms. Measuring Efficiency of an Algorithm. Algorithm and Data Structure Measuring Goodness of an Algorithm Asymptotic Analysis of Algorithms EECS2030 B: Advanced Object Oriented Programming Fall 2018 CHEN-WEI WANG 1. Correctness : Does the algorithm produce the expected output?

More information

Arithmetic with Whole Numbers and Money Variables and Evaluation

Arithmetic with Whole Numbers and Money Variables and Evaluation LESSON 1 Arithmetic with Whole Numbers and Money Variables and Evaluation Power Up 1 facts mental math Building Power Power Up A A score is 20. Two score and 4 is 44. How many is a. Measurement: 3 score

More information

Period 5: Thermal Energy, the Microscopic Picture

Period 5: Thermal Energy, the Microscopic Picture Name Section Period 5: Thermal Energy, the Microscopic Picture 5.1 How Is Temperature Related to Molecular Motion? 1) Temperature Your instructor will discuss molecular motion and temperature. a) At a

More information

PREFIXES AND SYMBOLS SI Prefixes you need to know by heart

PREFIXES AND SYMBOLS SI Prefixes you need to know by heart PREFIXES AND SYMBOLS SI Prefixes you need to know by heart Prefix Symbol In 10 n in Decimal Forms Giga G 10 9 1,000,000,000 Mega M 10 6 1,000,000 kilo k 10 3 1,000 deci d 10 1 0.1 centi c 10 2 0.01 milli

More information

Introduction to Hash Tables

Introduction to Hash Tables Introduction to Hash Tables Hash Functions A hash table represents a simple but efficient way of storing, finding, and removing elements. In general, a hash table is represented by an array of cells. In

More information

Chemistry 1104 Introduction:

Chemistry 1104 Introduction: Chemistry 1104 Introduction: Time requirements. Start early. Need help. See instructor early and often. Only requirement: be prepared. Understanding vs. memorization. Chemistry requires practice. Use problem

More information

GRADE LEVEL: THIRD SUBJECT: MATH DATE: CONTENT STANDARD INDICATORS SKILLS ASSESSMENT VOCABULARY ISTEP

GRADE LEVEL: THIRD SUBJECT: MATH DATE: CONTENT STANDARD INDICATORS SKILLS ASSESSMENT VOCABULARY ISTEP GRADE LEVEL: THIRD SUBJECT: MATH DATE: 2015 2016 GRADING PERIOD: QUARTER 1 MASTER COPY 9 24 15 CONTENT STANDARD INDICATORS SKILLS ASSESSMENT VOCABULARY ISTEP NUMBER SENSE Standard form Expanded form Models

More information

Each point on the thermometer can be represented by any number as long as the rest of the scale is relative.

Each point on the thermometer can be represented by any number as long as the rest of the scale is relative. The Three Big Temperature Scales Firstly, depending on the age and experience of the pupils, you may wish to recap on their understanding of scales and measures. The children will need to understand that

More information