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. Rimon Elias Dr. Hisham Othman 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 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 ; 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 ) ; 3

4 d3 will equal , and d4 will equal Exercise 1-4 Time To be discussed in Tutorial Write an algorithm that reads the amount of time in seconds and then displays the equivalent hours, minutes and remaining seconds. One hour corresponds to 60 minutes. One minute corresponds to 60 seconds. import j a v a. u t i l. Scanner ; p u b l i c c l a s s Time 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 seconds, minutes, h o u r s ; System. o u t. p r i n t l n ( " E n t e r number of s e c o n d s " ) ; s e c o n d s = sc. n e x t I n t ( ) ; h o u r s = s e c o n d s / 3600; s e c o n d s = s e c o n d s % 3600; m i n u t e s = s e c o n d s / 6 0 ; s e c o n d s = s e c o n d s % 6 0 ; System. o u t. p r i n t l n ( " Hours : " + h o u r s ) ; System. o u t. p r i n t l n ( " Minutes : " + m i n u t e s ) ; System. o u t. p r i n t l n ( " Seconds : " + s e c o n d s ) ; Exercise 1-5 Supermarket Change To be discussed in Tutorial 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. For example if we have: 3 quarters, 2 dimes, 1 nickle and 6 pennies, then the total is 1.06 dollars. Initializing variables by value: 4

5 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 / ) ; Initializing variables by input: import j a v a. u t i l. Scanner ; 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 ; System. o u t. p r i n t l n ( " E n t e r number of q u a r t e r s " ) ; q u a r t e r s = sc. n e x t I n t ( ) ; System. o u t. p r i n t l n ( " E n t e r number of dimes " ) ; dimes = sc. n e x t I n t ( ) ; System. o u t. p r i n t l n ( " E n t e r number of n i c k l e s " ) ; n i c k l e s = sc. n e x t I n t ( ) ; System. o u t. p r i n t l n ( " E n t e r number of p e n n i e s " ) ; p e n n i e s = sc. n e x t I n t ( ) ; 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 To be discussed in Lab 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 cylindrical pot. Write a program that, given the diameter of the pot and the height of the water in it, calculates the the time needed for the water to boil. Hint. The Volume of a cylinder 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 ; 5

6 / / 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 = ; 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 ( ) ; 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 ; 6

7 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. 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 ) 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 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 ; 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 ( ) ; 7

8 / / 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; 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. Mohammed Abdel Megeed Introduction to Computer Programming, Spring Term 2018 Practice Assignment 1 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 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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Measurements UNITS FOR MEASUREMENTS

Measurements UNITS FOR MEASUREMENTS Measurements UNITS FOR MEASUREMENTS Chemistry is an experimental science that requires the use of a standardized system of measurements. By international agreement in 1960, scientists around the world

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

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

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

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

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

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

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

Chapter 5 Assessment. 164 Chapter 5 Measurements and Calculations. 8. Write each of the following numbers in standard scientific notation. a.

Chapter 5 Assessment. 164 Chapter 5 Measurements and Calculations. 8. Write each of the following numbers in standard scientific notation. a. Chapter 5 Assessment All exercises with blue numbers have answers in the back of this book. 5.1 Scientific Notation and Units A. Scientific Notation 1. When the number 98,145 is written in standard scientific

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

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

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

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

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

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

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

MEASUREMENT IN THE LABORATORY

MEASUREMENT IN THE LABORATORY 1 MEASUREMENT IN THE LABORATORY INTRODUCTION Today's experiment will introduce you to some simple but important types of measurements commonly used by the chemist. You will measure lengths of objects,

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

1.5 Reporting Values from Measurements. Accuracy and Precision. 20 Chapter 1 An Introduction to Chemistry

1.5 Reporting Values from Measurements. Accuracy and Precision. 20 Chapter 1 An Introduction to Chemistry 20 Chapter 1 An Introduction to Chemistry 1.5 Reporting Values from Measurements All measurements are uncertain to some degree. Scientists are very careful to report the values of measurements in a way

More information

Released Assessment Questions, 2017 QUESTIONS. Grade 9 Assessment of Mathematics Academic LARGE PRINT

Released Assessment Questions, 2017 QUESTIONS. Grade 9 Assessment of Mathematics Academic LARGE PRINT Released Assessment Questions, 2017 QUESTIONS Grade 9 Assessment of Mathematics Academic LARGE PRINT page 2 Read the instructions below. Along with this booklet, make sure you have the Answer Booklet and

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

DISCRETE RANDOM VARIABLES EXCEL LAB #3

DISCRETE RANDOM VARIABLES EXCEL LAB #3 DISCRETE RANDOM VARIABLES EXCEL LAB #3 ECON/BUSN 180: Quantitative Methods for Economics and Business Department of Economics and Business Lake Forest College Lake Forest, IL 60045 Copyright, 2011 Overview

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

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

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

The Metric System and Measurement

The Metric System and Measurement The Metric System and Measurement Introduction The metric system is the world standard for measurement. Not only is it used by scientists throughout the world, but most nations have adopted it as their

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

Digital Electronics Part 1: Binary Logic

Digital Electronics Part 1: Binary Logic Digital Electronics Part 1: Binary Logic Electronic devices in your everyday life What makes these products examples of electronic devices? What are some things they have in common? 2 How do electronics

More information

Take-home Lab 1. Arrays

Take-home Lab 1. Arrays Take-home Lab 1 Arrays Findx 2-Dimensional Array Graded! Submit by Friday 23:59 Find You are given a treasure map by your friend Map is divided into R by C cells Super Marks The Spot You need to find all

More information

Quiz 2 Room 10 Evans Hall, 2:10pm Tuesday April 2 (Open Katz only, Calculators OK, 1hr 20mins)

Quiz 2 Room 10 Evans Hall, 2:10pm Tuesday April 2 (Open Katz only, Calculators OK, 1hr 20mins) Your Name: NIVERSITY OF CALIFORNIA AT BERKELEY RKELEY DAVIS IRVINE LOS ANGELES RIVERSIDE SAN DIEGO SAN FRANCISCO Department of Electrical Engineering and Computer Sciences SANTA BARBARA SANTA CRUZ CS 150

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

EE260: Digital Design, Spring n Digital Computers. n Number Systems. n Representations. n Conversions. n Arithmetic Operations.

EE260: Digital Design, Spring n Digital Computers. n Number Systems. n Representations. n Conversions. n Arithmetic Operations. EE 260: Introduction to Digital Design Number Systems Yao Zheng Department of Electrical Engineering University of Hawaiʻi at Mānoa Overview n Digital Computers n Number Systems n Representations n Conversions

More information

Solutions to Second Midterm

Solutions to Second Midterm Operations Management 33:623:386:04/05 Professor Eckstein, Spring 2002 Solutions to Second Midterm Q1 Q2 Q3 Total Max 35 33 30 94 Mean 25.9 26.4 27.6 79.8 Median 27.0 27.0 28.0 81.0 Min 8 15 20 50 Standard

More information

KINETICS II - THE IODINATION OF ACETONE Determining the Activation Energy for a Chemical Reaction

KINETICS II - THE IODINATION OF ACETONE Determining the Activation Energy for a Chemical Reaction KINETICS II - THE IODINATION OF ACETONE Determining the Activation Energy for a Chemical Reaction The rate of a chemical reaction depends on several factors: the nature of the reaction, the concentrations

More information

ECE20B Final Exam, 200 Point Exam Closed Book, Closed Notes, Calculators Not Allowed June 12th, Name

ECE20B Final Exam, 200 Point Exam Closed Book, Closed Notes, Calculators Not Allowed June 12th, Name C20B Final xam, 200 Point xam Closed Book, Closed Notes, Calculators Not llowed June 2th, 2003 Name Guidelines: Please remember to write your name on your bluebook, and when finished, to staple your solutions

More information

Chapter 4 Number Representations

Chapter 4 Number Representations Chapter 4 Number Representations SKEE2263 Digital Systems Mun im/ismahani/izam {munim@utm.my,e-izam@utm.my,ismahani@fke.utm.my} February 9, 2016 Table of Contents 1 Fundamentals 2 Signed Numbers 3 Fixed-Point

More information

Name: Measurements and Calculations (Chapter 3 and 4) Notes

Name: Measurements and Calculations (Chapter 3 and 4) Notes Name: Measurements and Calculations (Chapter 3 and 4) Notes I. Scientific Method - the process researchers use to carry out their investigations. It is a logical approach to solving problems. A. Steps

More information

Project 3: Hadoop Blast Cloud Computing Spring 2017

Project 3: Hadoop Blast Cloud Computing Spring 2017 Project 3: Hadoop Blast Cloud Computing Spring 2017 Professor Judy Qiu Goal By this point you should have gone over the sections concerning Hadoop Setup and a few Hadoop programs. Now you are going to

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

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

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

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

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

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

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

Scientific Method. Why Study Chemistry? Why Study Chemistry? Chemistry has many applications to our everyday world. 1. Materials. Areas of Chemistry

Scientific Method. Why Study Chemistry? Why Study Chemistry? Chemistry has many applications to our everyday world. 1. Materials. Areas of Chemistry August 12, 2012 Introduction to Chemistry and Scientific Measurement What is Chemistry? Chemistry: is the study of the composition of matter and the changes that matter undergoes. Chapters 1 and 3 Why

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

Computer Architecture, IFE CS and T&CS, 4 th sem. Representation of Integer Numbers in Computer Systems

Computer Architecture, IFE CS and T&CS, 4 th sem. Representation of Integer Numbers in Computer Systems Representation of Integer Numbers in Computer Systems Positional Numbering System Additive Systems history but... Roman numerals Positional Systems: r system base (radix) A number value a - digit i digit

More information

PAST EXAM PAPER & MEMO N3 ABOUT THE QUESTION PAPERS:

PAST EXAM PAPER & MEMO N3 ABOUT THE QUESTION PAPERS: EKURHULENI TECH COLLEGE. No. 3 Mogale Square, Krugersdorp. Website: www. ekurhulenitech.co.za Email: info@ekurhulenitech.co.za TEL: 011 040 7343 CELL: 073 770 3028/060 715 4529 PAST EXAM PAPER & MEMO N3

More information

How do computers represent numbers?

How do computers represent numbers? How do computers represent numbers? Tips & Tricks Week 1 Topics in Scientific Computing QMUL Semester A 2017/18 1/10 What does digital mean? The term DIGITAL refers to any device that operates on discrete

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

EXPERIMENT 1 Chemistry 110 LABORATORY SAFETY

EXPERIMENT 1 Chemistry 110 LABORATORY SAFETY EXPERIMENT 1 Chemistry 110 LABORATORY SAFETY MEASUREMENTS PURPOSE: The Purpose of this laboratory exercise is for the students to develop the skills of measuring length, volume, mass and temperature and

More information

BIO Lab 3: Measurements

BIO Lab 3: Measurements Measurements All Wisdom is from the Lord God and has been always with Him and is before all time. Who has numbered the sand of the sea, and the drops of rain, and the days of the world? Who has measured

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

DARN: A Matrix Manipulation Language

DARN: A Matrix Manipulation Language DARN: A Matrix Manipulation Language Daisy Chaussee (dac2183) Anthony Kim (ak3703) Rafael Takasu (rgt2108) Ignacio (Nacho) Torras (it2216) December 20, 2016 1 Contents 1 Introduction to the Language 4

More information

ECE 372 Microcontroller Design

ECE 372 Microcontroller Design Data Formats Humor There are 10 types of people in the world: Those who get binary and those who don t. 1 Information vs. Data Information An abstract description of facts, processes or perceptions How

More information

DESIGN AND IMPLEMENTATION OF ENCODERS AND DECODERS. To design and implement encoders and decoders using logic gates.

DESIGN AND IMPLEMENTATION OF ENCODERS AND DECODERS. To design and implement encoders and decoders using logic gates. DESIGN AND IMPLEMENTATION OF ENCODERS AND DECODERS AIM To design and implement encoders and decoders using logic gates. COMPONENTS REQUIRED S.No Components Specification Quantity 1. Digital IC Trainer

More information

Prepare for this experiment!

Prepare for this experiment! Notes on Experiment #8 Theorems of Linear Networks Prepare for this experiment! If you prepare, you can finish in 90 minutes. If you do not prepare, you will not finish even half of this experiment. So,

More information

Digital Systems Roberto Muscedere Images 2013 Pearson Education Inc. 1

Digital Systems Roberto Muscedere Images 2013 Pearson Education Inc. 1 Digital Systems Digital systems have such a prominent role in everyday life The digital age The technology around us is ubiquitous, that is we don t even notice it anymore Digital systems are used in:

More information

Chapter: Measurement

Chapter: Measurement Table of Contents Chapter: Measurement Section 1: Description and Measurement Section 2: SI Units *Section 1 Description and Measurements Measurement Measurement is a way to describe the world with numbers.

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

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

Community Collaborative RAin, Hail and Snow network. CoCoRaHS.

Community Collaborative RAin, Hail and Snow network. CoCoRaHS. Community Collaborative RAin, Hail and Snow network CoCoRaHS http://ks.cocorahs.org An observer s guide to measuring and reporting precipitation data! Equipment Each volunteer participating in CoCoRaHS

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

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