(I m not printing out these notes! Take your own.)

Size: px
Start display at page:

Download "(I m not printing out these notes! Take your own.)"

Transcription

1 PT1420 Week 2: Software Program Design I (I m not printing out these notes! Take your own.) Today we'll be discussing designing programs: Algorithms and errors Flowcharts and pseudocode Sequence structures Variables, constants, and the order of operations We re in the first part of Chapter 2, from pages 29 55: 2.1: Designing a Program, pages 29 34; 2.2: Output, Input, and Variables, pages 34 43; and 2.3: Variable Assignment and Calculations, pages If you want a paper copy of the textbook, or of the PowerPoint I m not using, it s up at the front by the sign in sheet. We ll be working, to start, with a program which does the following: If I know how many hours I worked, and I know how much I get paid per hour, how much money am I owed? We ll later be adjusting this to tell me not only how much am I owed, but how much will I get after taxes. (We are probably not going to deal yet with overtime, but if we don t we ll discuss why.) The Three Step Process of Programming Broadly speaking, there are three big steps which programs do when they run. 1. They take some sort of input. (This step is sometimes, rarely, skipped.) 2. They do something (to it) some sort of process. 3. They produce some sort of output.

2 This is illustrated on page 34, the Input > Process > Output steps. We re looking today at the Process step. We ll take input from the keyboard and output to the screen. We ll use Raptor to make a flowchart and run it. The Software Development Process The software development cycle is really high level illustrated on page 30: The design the program step is the hard one. (This is part contract/specification to protect you from disagreements/lawsuits.) This is also where you d perhaps want to start making flowcharts or using pseudocode. You d then write code. The first type of error you might find are syntax errors. This is an error in programming which prevents the program from even running (or compiling). 3+ is an example of a math expression with a syntax error; that plus sign needs to have something after it. Once your program runs (there are no more syntax errors) it may still have bugs. (It will have bugs.) These will be logic errors. The program is doing what you said as opposed to what you meant.

3 This is an important distinction, syntax errors versus logic errors. Logic errors are harder to find. The design step involves working out the algorithm you intend your program to use. These are the steps you re going to use to use to perform the tasks. There s an example on page 31: The problem we had above (with the paycheck) could have an algorithm like this: 1. Ask the user how many hours he worked. 2. (Store that number of hours in a variable.) 3. Ask the user how much he makes per hour. 4. (Store that number, of dollars and cents, in a different variable.) 5. Calculate the pay, by multiplying those two variables together and storing that product in a third variable. 6. Display the pay the user should expect (that third variable). This algorithm is a sequential structure because the steps are performed in order straight down. The other two control structures are decision structures (if then branching) and repetition structures (loops). This algorithm has three variables: The number of hours worked The amount of pay per hour

4 Gross pay There are rules and good practice about naming variables. You can t start a variable name with a number. You can t have a space in a variable name. You can t have weird characters in variable names. For example, a%b is not a valid variable name, but it may not produce a syntax error because in some programming languages a%b means the remainder when a is divided by b (it s called modulo). You do want to make your variable names useful. HoursWorked is a good variable name in this program. Don t make them really long. You may see variables always starting with lower case, for example hoursworked. (This is called camel case.) You may be able to use an underscore, Hours_Worked, if that s useful. You don t want to use ALL CAPS: HOURSWORKED. In most environments, all caps means that a variable is a constant. For example, PI= could be a definition of the PI variable as a constant We ll talk more about constants. You only want to use short variables like i, a, b, x, when you re doing something really short and obvious. For example, for (i=1, i<10, i++) { print i; } is a loop which just prints the numbers Using i is ok here because its use is brief and obvious. Back to this algorithm with variables: The number of hours worked: HoursWorked [number with decimals, a floating point number] The amount of pay per hour: PayPerHour [number with decimals, a floating point number]

5 Gross pay: GrossPay [number with decimals, a floating point number] We re going to look at making pseudocode for this task, and also at using Raptor to make a flowchart and running it. Pseudocode could look like: 1. Print How many hours did you work? 2. Input HoursWorked 3. Print How much is your hourly pay? 4. Input PayPerHour 5. Set GrossPay = HoursWorked * PayPerHour 6. Print Your paycheck should be for $, GrossPay One last topic: Variables, constants, and the order of operations We ve spoken briefly about variables. You want to name your variables sensibly. You want to figure out in advance which variables you need, and what sort of data is stored in them. Some common sorts of data are integers, floating point numbers, character, string (of characters), or boolean (true/false bits). Sometimes you define a variable as a constant, which means (1) the value won t change, (2) the value can t change, and (3) the compiler may do things to make your use of that variable more efficient. const PI= const COMPANY_NAME= ITT Technical Institute, Inc. const MINIMUM_WAGE=7.25 Programs also use constants. Constants can be numbers. 1, 2, Think carefully about using constants in your code should they be constants?

6 String constants are common. When we said How many hours did you work? we created a string constant. When we want to set or change variables, we use the Order of Operations (PEMDAS). First comes parentheses, from the inside out. Use parentheses every time you think you re doing something confusing. GrossPay = (HourlyWage * HoursWorked) Next comes exponents. Usually this uses the character ^ or **. 2^3 would be 8 (2x2x2=8). Some languages would say 2**3. Multiplication * and Division / left to right. Multiplication uses the * character. Division uses the / character. Think carefully about using parentheses here if your math is complicated. Addition and Subtraction, left to right. Usual symbols, + and. Again, use parentheses if your math is complicated. The syntax for setting a variable s value is Variable Name = some expression and the variable s name must be alone on the left hand side. If I have a statement (p. 49) Set outcome = / 3 I might want to write it Set outcome = 12 + (6 / 3) because even though the parentheses are unnecessary, putting them there makes it clear to me when I look at it that that part happens first. and maybe what I wanted was Set outcome = (12 + 6) / 6

DECISION STRUCTURES: USING IF STATEMENTS IN JAVA

DECISION STRUCTURES: USING IF STATEMENTS IN JAVA DECISION STRUCTURES: USING IF STATEMENTS IN JAVA S o far all the programs we have created run straight through from start to finish, without making any decisions along the way. Many times, however, you

More information

Midterms Save the Dates!

Midterms Save the Dates! University of British Columbia CPSC 111, Intro to Computation Alan J. Hu Primitive Data Types Arithmetic Operators Readings Your textbook is Big Java (3rd Ed). This Week s Reading: Ch 2.1-2.5, Ch 4.1-4.2.

More information

SAMLab Tip Sheet #1 Translating Mathematical Formulas Into Excel s Language

SAMLab Tip Sheet #1 Translating Mathematical Formulas Into Excel s Language Translating Mathematical Formulas Into Excel s Language Introduction Microsoft Excel is a very powerful calculator; you can use it to compute a wide variety of mathematical expressions. Before exploring

More information

QUICK EXCEL TUTORIAL. The Very Basics

QUICK EXCEL TUTORIAL. The Very Basics QUICK EXCEL TUTORIAL The Very Basics You Are Here. Titles & Column Headers Merging Cells Text Alignment When we work on spread sheets we often need to have a title and/or header clearly visible. Merge

More information

Lesson 2A Data. Data Types, Variables, Constants, Naming Rules, Limits. A Lesson in Java Programming

Lesson 2A Data. Data Types, Variables, Constants, Naming Rules, Limits. A Lesson in Java Programming Lesson 2A Data Data Types, Variables, Constants, Naming Rules, Limits A Lesson in Java Programming Based on the O(N)CS Lesson Series License for use granted by John Owen to the University of Texas at Austin,

More information

Lecture 3. Input, Output and Data Types

Lecture 3. Input, Output and Data Types Lecture 3 Input, Output and Data Types Goals for today Variable Types Integers, Floating-Point, Strings, Booleans Conversion between types Operations on types Input/Output Some ways of getting input, and

More information

1 Introduction Java, the beginning Java Virtual Machine A First Program BlueJ Raspberry Pi...

1 Introduction Java, the beginning Java Virtual Machine A First Program BlueJ Raspberry Pi... Contents 1 Introduction 3 1.1 Java, the beginning.......................... 3 1.2 Java Virtual Machine........................ 4 1.3 A First Program........................... 4 1.4 BlueJ.................................

More information

3. Simple Types, Variables, and Constants

3. Simple Types, Variables, and Constants 3. Simple Types, Variables, and Constants This section of the lectures will look at simple containers in which you can storing single values in the programming language C++. You might find it interesting

More information

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA 1 TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson, and instructor materials prepared

More information

Com S 127x - Lab 6 1. READING FLOWCHARTS WITH CONDITIONAL ACTIONS!

Com S 127x - Lab 6 1. READING FLOWCHARTS WITH CONDITIONAL ACTIONS! Com S 127x - Lab 6 1. READING FLOWCHARTS WITH CONDITIONAL ACTIONS! The U.S. Postal Service has some complex rules for deciding how much it costs to mail a letter. We ll use a small part of these rules

More information

Section 0.3 The Order of Operations

Section 0.3 The Order of Operations Section 0.3 The Contents: Evaluating an Expression Grouping Symbols OPERATIONS The Distributive Property Answers Focus Exercises Let s be reminded of those operations seen thus far in the course: Operation

More information

T H E I N T E R A C T I V E S H E L L

T H E I N T E R A C T I V E S H E L L 3 T H E I N T E R A C T I V E S H E L L The Analytical Engine has no pretensions whatever to originate anything. It can do whatever we know how to order it to perform. Ada Lovelace, October 1842 Before

More information

Modular Arithmetic. Marizza Bailey. December 14, 2015

Modular Arithmetic. Marizza Bailey. December 14, 2015 Modular Arithmetic Marizza Bailey December 14, 2015 Introduction to Modular Arithmetic If someone asks you what day it is 145 days from now, what would you answer? Would you count 145 days, or find a quicker

More information

Lecture Transcript While and Do While Statements in C++

Lecture Transcript While and Do While Statements in C++ Lecture Transcript While and Do While Statements in C++ Hello and welcome back. In this lecture we are going to look at the while and do...while iteration statements in C++. Here is a quick recap of some

More information

DATA AND ABSTRACTION. Today you will learn : How to work with variables How to break a program down Good program design

DATA AND ABSTRACTION. Today you will learn : How to work with variables How to break a program down Good program design DATA AND ABSTRACTION Today you will learn : How to work with variables How to break a program down Good program design VARIABLES Variables are a named memory location Before you use a variable you must

More information

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet. Mr G s Java Jive #2: Yo! Our First Program With this handout you ll write your first program, which we ll call Yo. Programs, Classes, and Objects, Oh My! People regularly refer to Java as a language that

More information

CS1 Lecture 3 Jan. 22, 2018

CS1 Lecture 3 Jan. 22, 2018 CS1 Lecture 3 Jan. 22, 2018 Office hours for me and for TAs have been posted, locations will change check class website regularly First homework available, due Mon., 9:00am. Discussion sections tomorrow

More information

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2.

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2. Class #10: Understanding Primitives and Assignments Software Design I (CS 120): M. Allen, 19 Sep. 18 Java Arithmetic } Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = 2 + 5 / 2; 3.

More information

Discussion 1H Notes (Week 2, 4/8) TA: Brian Choi Section Webpage:

Discussion 1H Notes (Week 2, 4/8) TA: Brian Choi Section Webpage: Discussion 1H Notes (Week 2, 4/8) TA: Brian Choi (schoi@cs.ucla.edu) Section Webpage: http://www.cs.ucla.edu/~schoi/cs31 Variables You have to instruct your computer every little thing it needs to do even

More information

Chapter 2: Input, Processing, and Output

Chapter 2: Input, Processing, and Output Chapter 2: Input, Processing, and Output Starting Out with Programming Logic & Design Second Edition by Tony Gaddis Copyright 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter Topics

More information

CS 115 Data Types and Arithmetic; Testing. Taken from notes by Dr. Neil Moore

CS 115 Data Types and Arithmetic; Testing. Taken from notes by Dr. Neil Moore CS 115 Data Types and Arithmetic; Testing Taken from notes by Dr. Neil Moore Statements A statement is the smallest unit of code that can be executed on its own. So far we ve seen simple statements: Assignment:

More information

Chapter 2. Designing a Program. Input, Processing, and Output Fall 2016, CSUS. Chapter 2.1

Chapter 2. Designing a Program. Input, Processing, and Output Fall 2016, CSUS. Chapter 2.1 Chapter 2 Input, Processing, and Output Fall 2016, CSUS Designing a Program Chapter 2.1 1 Algorithms They are the logic on how to do something how to compute the value of Pi how to delete a file how to

More information

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Lecture 15 Branching : IF ELSE Statement We are looking

More information

ENGR 101 Engineering Design Workshop

ENGR 101 Engineering Design Workshop ENGR 101 Engineering Design Workshop Lecture 2: Variables, Statements/Expressions, if-else Edgardo Molina City College of New York Literals, Variables, Data Types, Statements and Expressions Python as

More information

n = 1 What problems are interesting when n is just 1?

n = 1 What problems are interesting when n is just 1? What if n=1??? n = 1 What problems are interesting when n is just 1? Sorting? No Median finding? No Addition? How long does it take to add one pair of numbers? Multiplication? How long does it take to

More information

Lecture 2: SML Basics

Lecture 2: SML Basics 15-150 Lecture 2: SML Basics Lecture by Dan Licata January 19, 2012 I d like to start off by talking about someone named Alfred North Whitehead. With someone named Bertrand Russell, Whitehead wrote Principia

More information

Chapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Chapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved. Chapter 2 C++ Basics 1 Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style Slide 2-3 2.1 Variables and Assignments 2

More information

Section we will not cover section 2.11 feel free to read it on your own

Section we will not cover section 2.11 feel free to read it on your own Operators Class 5 Section 2.11 we will not cover section 2.11 feel free to read it on your own Data Types Data Type A data type is a set of values and a set of operations defined on those values. in class

More information

Variables, expressions and statements

Variables, expressions and statements Variables, expressions and statements 2.1. Values and data types A value is one of the fundamental things like a letter or a number that a program manipulates. The values we have seen so far are 2 (the

More information

SNS COLLEGE OF ENGINEERING

SNS COLLEGE OF ENGINEERING SNS COLLEGE OF ENGINEERING DEPARTMENT OF CSE Presented By Thillaiarasu.N SCRAMBLE 2 Solution 3 What is Pseudocode? 4 Consists of: Short Readable Formally styled English language Used for: Explaining the

More information

CS1 Lecture 3 Jan. 18, 2019

CS1 Lecture 3 Jan. 18, 2019 CS1 Lecture 3 Jan. 18, 2019 Office hours for Prof. Cremer and for TAs have been posted. Locations will change check class website regularly First homework assignment will be available Monday evening, due

More information

Topic 2: Decimals. Topic 1 Integers. Topic 2 Decimals. Topic 3 Fractions. Topic 4 Ratios. Topic 5 Percentages. Topic 6 Algebra

Topic 2: Decimals. Topic 1 Integers. Topic 2 Decimals. Topic 3 Fractions. Topic 4 Ratios. Topic 5 Percentages. Topic 6 Algebra 41 Topic 2: Decimals Topic 1 Integers Topic 2 Decimals Topic 3 Fractions Topic 4 Ratios Duration 1/2 week Content Outline Introduction Addition and Subtraction Multiplying and Dividing by Multiples of

More information

Mr G s Java Jive. #11: Formatting Numbers

Mr G s Java Jive. #11: Formatting Numbers Mr G s Java Jive #11: Formatting Numbers Now that we ve started using double values, we re bound to run into the question of just how many decimal places we want to show. This where we get to deal with

More information

2 A little on Spreadsheets

2 A little on Spreadsheets 2 A little on Spreadsheets Spreadsheets are computer versions of an accounts ledger. They are used frequently in business, but have wider uses. In particular they are often used to manipulate experimental

More information

Properties and Definitions

Properties and Definitions Section 0.1 Contents: Operations Defined Multiplication as an Abbreviation Visualizing Multiplication Commutative Properties Parentheses Associative Properties Identities Zero Product Answers to Exercises

More information

Our Strategy for Learning Fortran 90

Our Strategy for Learning Fortran 90 Our Strategy for Learning Fortran 90 We want to consider some computational problems which build in complexity. evaluating an integral solving nonlinear equations vector/matrix operations fitting data

More information

Spring 2017 CMSC 140 Programming Project 7: Payroll

Spring 2017 CMSC 140 Programming Project 7: Payroll Spring 2017 CMSC 140 Programming Project 7: Payroll Concepts tested by the program: 1. Working with arrays 2. Using file operations 3. Using a selection sort to sort parallel arrays 4. Using a binary search

More information

Part II Composition of Functions

Part II Composition of Functions Part II Composition of Functions The big idea in this part of the book is deceptively simple. It s that we can take the value returned by one function and use it as an argument to another function. By

More information

9/2/2016. Expressions are Used to Perform Calculations. ECE 120: Introduction to Computing. Five Arithmetic Operators on Numeric Types

9/2/2016. Expressions are Used to Perform Calculations. ECE 120: Introduction to Computing. Five Arithmetic Operators on Numeric Types University of Illinois at Urbana-Champaign Dept. of Electrical and Computer Engineering ECE 120: Introduction to Computing Expressions are Used to Perform Calculations Let s talk in more detail starting

More information

1/31/2017. Expressions are Used to Perform Calculations. ECE 120: Introduction to Computing. Five Arithmetic Operators on Numeric Types

1/31/2017. Expressions are Used to Perform Calculations. ECE 120: Introduction to Computing. Five Arithmetic Operators on Numeric Types University of Illinois at Urbana-Champaign Dept. of Electrical and Computer Engineering ECE 120: Introduction to Computing Expressions are Used to Perform Calculations Let s talk in more detail starting

More information

KNOWLEDGE OF NUMBER SENSE, CONCEPTS, AND OPERATIONS

KNOWLEDGE OF NUMBER SENSE, CONCEPTS, AND OPERATIONS DOMAIN I. COMPETENCY 1.0 MATHEMATICS KNOWLEDGE OF NUMBER SENSE, CONCEPTS, AND OPERATIONS Skill 1.1 Compare the relative value of real numbers (e.g., integers, fractions, decimals, percents, irrational

More information

CHAPTER 1: INTEGERS. Image from CHAPTER 1 CONTENTS

CHAPTER 1: INTEGERS. Image from  CHAPTER 1 CONTENTS CHAPTER 1: INTEGERS Image from www.misterteacher.com CHAPTER 1 CONTENTS 1.1 Introduction to Integers 1. Absolute Value 1. Addition of Integers 1.4 Subtraction of Integers 1.5 Multiplication and Division

More information

Review. Input, Processing and Output. Review. Review. Designing a Program. Typical Software Development cycle. Bonita Sharif

Review. Input, Processing and Output. Review. Review. Designing a Program. Typical Software Development cycle. Bonita Sharif Input, Processing and Output Bonita Sharif 1 Review A program is a set of instructions a computer follows to perform a task The CPU is responsible for running and executing programs A set of instructions

More information

Chapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Chapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved. Chapter 2 C++ Basics Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style 3 2.1 Variables and Assignments Variables and

More information

Chapter 2. C++ Basics

Chapter 2. C++ Basics Chapter 2 C++ Basics Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style Slide 2-2 2.1 Variables and Assignments Variables

More information

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types

More information

Last Time. University of British Columbia CPSC 111, Intro to Computation Alan J. Hu. Readings

Last Time. University of British Columbia CPSC 111, Intro to Computation Alan J. Hu. Readings University of British Columbia CPSC 111, Intro to Computation Alan J. Hu Writing a Simple Java Program Intro to Variables Readings Your textbook is Big Java (3rd Ed). This Week s Reading: Ch 2.1-2.5, Ch

More information

2SKILL. Variables Lesson 6. Remembering numbers (and other stuff)...

2SKILL. Variables Lesson 6. Remembering numbers (and other stuff)... Remembering numbers (and other stuff)... Let s talk about one of the most important things in any programming language. It s called a variable. Don t let the name scare you. What it does is really simple.

More information

COMP-202 Unit 2: Java Basics. CONTENTS: Using Expressions and Variables Types Strings Methods

COMP-202 Unit 2: Java Basics. CONTENTS: Using Expressions and Variables Types Strings Methods COMP-202 Unit 2: Java Basics CONTENTS: Using Expressions and Variables Types Strings Methods Assignment 1 Assignment 1 posted on WebCt and course website. It is due May 18th st at 23:30 Worth 6% Part programming,

More information

Programming Logic and Design Seventh Edition Chapter 2 Elements of High-Quality Programs

Programming Logic and Design Seventh Edition Chapter 2 Elements of High-Quality Programs Programming Logic and Design Chapter 2 Elements of High-Quality Programs Objectives In this chapter, you will learn about: Declaring and using variables and constants Assigning values to variables [assignment

More information

CS102: Variables and Expressions

CS102: Variables and Expressions CS102: Variables and Expressions The topic of variables is one of the most important in C or any other high-level programming language. We will start with a simple example: int x; printf("the value of

More information

Topic Notes: Bits and Bytes and Numbers

Topic Notes: Bits and Bytes and Numbers Computer Science 220 Assembly Language & Comp Architecture Siena College Fall 2011 Topic Notes: Bits and Bytes and Numbers Binary Basics At least some of this will be review for most of you, but we start

More information

ITSE 1411 Beg. Web Programming

ITSE 1411 Beg. Web Programming (JavaScript, Sequence, Functions) Last revised: 4/17/14 Directions: Perform the tasks below on your personal computer or a lab computer. This document shows the score points for each task in parentheses.

More information

Fundamentals. Fundamentals. Fundamentals. We build up instructions from three types of materials

Fundamentals. Fundamentals. Fundamentals. We build up instructions from three types of materials Fundamentals We build up instructions from three types of materials Constants Expressions Fundamentals Constants are just that, they are values that don t change as our macros are executing Fundamentals

More information

Expressions and Casting. Data Manipulation. Simple Program 11/5/2013

Expressions and Casting. Data Manipulation. Simple Program 11/5/2013 Expressions and Casting C# Programming Rob Miles Data Manipulation We know that programs use data storage (variables) to hold values and statements to process the data The statements are obeyed in sequence

More information

AP Computer Science A

AP Computer Science A AP Computer Science A 1st Quarter Notes Table of Contents - section links Click on the date or topic below to jump to that section Date : 9/8/2017 Aim : Java Basics Objects and Classes Data types: Primitive

More information

Chapter 2: Data and Expressions

Chapter 2: Data and Expressions Chapter 2: Data and Expressions CS 121 Department of Computer Science College of Engineering Boise State University August 21, 2017 Chapter 2: Data and Expressions CS 121 1 / 51 Chapter 1 Terminology Review

More information

CS1 Lecture 5 Jan. 25, 2019

CS1 Lecture 5 Jan. 25, 2019 CS1 Lecture 5 Jan. 25, 2019 HW1 due Monday, 9:00am. Notes: Do not write all the code at once before starting to test. Take tiny steps. Write a few lines test... add a line or two test... add another line

More information

Review. Modules. CS 151 Review #6. Sample Program 6.1a:

Review. Modules. CS 151 Review #6. Sample Program 6.1a: Review Modules A key element of structured (well organized and documented) programs is their modularity: the breaking of code into small units. These units, or modules, that do not return a value are called

More information

Algorithms and Programming I. Lecture#12 Spring 2015

Algorithms and Programming I. Lecture#12 Spring 2015 Algorithms and Programming I Lecture#12 Spring 2015 Think Python How to Think Like a Computer Scientist By :Allen Downey Installing Python Follow the instructions on installing Python and IDLE on your

More information

Computer Science 210: Data Structures

Computer Science 210: Data Structures Computer Science 210: Data Structures Welcome to Data Structures! Data structures are fundamental building blocks of algorithms and programs Csci 210 is a study of data structures design efficiency implementation

More information

Intermediate Algebra. Gregg Waterman Oregon Institute of Technology

Intermediate Algebra. Gregg Waterman Oregon Institute of Technology Intermediate Algebra Gregg Waterman Oregon Institute of Technology c 2017 Gregg Waterman This work is licensed under the Creative Commons Attribution 4.0 International license. The essence of the license

More information

VARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs.

VARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs. Lesson 2 VARIABLES Aim Understanding how computer programs store values, and how they are accessed and used in computer programs. WHAT ARE VARIABLES? When you input data (i.e. information) into a computer

More information

Expressions and Casting

Expressions and Casting Expressions and Casting C# Programming Rob Miles Data Manipulation We know that programs use data storage (variables) to hold values and statements to process the data The statements are obeyed in sequence

More information

The sequence of steps to be performed in order to solve a problem by the computer is known as an algorithm.

The sequence of steps to be performed in order to solve a problem by the computer is known as an algorithm. CHAPTER 1&2 OBJECTIVES After completing this chapter, you will be able to: Understand the basics and Advantages of an algorithm. Analysis various algorithms. Understand a flowchart. Steps involved in designing

More information

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. A Guide to this Instructor s Manual:

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. A Guide to this Instructor s Manual: Java Programming, Eighth Edition 2-1 Chapter 2 Using Data A Guide to this Instructor s Manual: We have designed this Instructor s Manual to supplement and enhance your teaching experience through classroom

More information

Computer Programming. Basic Control Flow - Loops. Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons

Computer Programming. Basic Control Flow - Loops. Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons Computer Programming Basic Control Flow - Loops Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons Objectives To learn about the three types of loops: while for do To avoid infinite

More information

Topic Notes: Bits and Bytes and Numbers

Topic Notes: Bits and Bytes and Numbers Computer Science 220 Assembly Language & Comp Architecture Siena College Fall 2010 Topic Notes: Bits and Bytes and Numbers Binary Basics At least some of this will be review, but we will go over it for

More information

Chapter 17. Fundamental Concepts Expressed in JavaScript

Chapter 17. Fundamental Concepts Expressed in JavaScript Chapter 17 Fundamental Concepts Expressed in JavaScript Learning Objectives Tell the difference between name, value, and variable List three basic data types and the rules for specifying them in a program

More information

LESSON 2 VARIABLES, OPERATORS, EXPRESSIONS, AND USER INPUT

LESSON 2 VARIABLES, OPERATORS, EXPRESSIONS, AND USER INPUT LESSON VARIABLES, OPERATORS, EXPRESSIONS, AND USER INPUT PROF. JOHN P. BAUGH PROFJPBAUGH@GMAIL.COM PROFJPBAUGH.COM CONTENTS INTRODUCTION... Assumptions.... Variables and Data Types..... Numeric Data Types:

More information

Programming Language 2 (PL2)

Programming Language 2 (PL2) Programming Language 2 (PL2) 337.1.1 - Explain rules for constructing various variable types of language 337.1.2 Identify the use of arithmetical and logical operators 337.1.3 Explain the rules of language

More information

Computing Seminar Introduction Oct

Computing Seminar Introduction Oct Computing Seminar Introduction Oct 6 2010 Outline today Programming/computing basics terminology, high level concepts (variables, control flow, input/output) Before next week... Make sure you can login

More information

Control Structures. Lecture 4 COP 3014 Fall September 18, 2017

Control Structures. Lecture 4 COP 3014 Fall September 18, 2017 Control Structures Lecture 4 COP 3014 Fall 2017 September 18, 2017 Control Flow Control flow refers to the specification of the order in which the individual statements, instructions or function calls

More information

On a 64-bit CPU. Size/Range vary by CPU model and Word size.

On a 64-bit CPU. Size/Range vary by CPU model and Word size. On a 64-bit CPU. Size/Range vary by CPU model and Word size. unsigned short x; //range 0 to 65553 signed short x; //range ± 32767 short x; //assumed signed There are (usually) no unsigned floats or doubles.

More information

Introduction to Computer Use II

Introduction to Computer Use II Winter 2005 (Section M) Topic B: Variables, Data Types and Expressions Wednesday, January 18 2006 COSC 1530, Winter 2006, Overview (1): Before We Begin Some administrative details Some questions to consider

More information

CISC-124. Casting. // this would fail because we can t assign a double value to an int // variable

CISC-124. Casting. // this would fail because we can t assign a double value to an int // variable CISC-124 20180122 Today we looked at casting, conditionals and loops. Casting Casting is a simple method for converting one type of number to another, when the original type cannot be simply assigned to

More information

Post Experiment Interview Questions

Post Experiment Interview Questions Post Experiment Interview Questions Questions about the Maximum Problem 1. What is this problem statement asking? 2. What is meant by positive integers? 3. What does it mean by the user entering valid

More information

GENERAL MATH FOR PASSING

GENERAL MATH FOR PASSING GENERAL MATH FOR PASSING Your math and problem solving skills will be a key element in achieving a passing score on your exam. It will be necessary to brush up on your math and problem solving skills.

More information

Civil Engineering Computation

Civil Engineering Computation Civil Engineering Computation First Steps in VBA Homework Evaluation 2 1 Homework Evaluation 3 Based on this rubric, you may resubmit Homework 1 and Homework 2 (along with today s homework) by next Monday

More information

1 Anatomy of a Program 4

1 Anatomy of a Program 4 Objectives Anatomy of a Program 1E3 To understand the role of basic C++ program elements. To provide a skeleton from which to generate simple programs. 1 Anatomy of a Program 1 1 Anatomy of a Program 2

More information

Introduction to C Final Review Chapters 1-6 & 13

Introduction to C Final Review Chapters 1-6 & 13 Introduction to C Final Review Chapters 1-6 & 13 Variables (Lecture Notes 2) Identifiers You must always define an identifier for a variable Declare and define variables before they are called in an expression

More information

1. What type of error produces incorrect results but does not prevent the program from running? a. syntax b. logic c. grammatical d.

1. What type of error produces incorrect results but does not prevent the program from running? a. syntax b. logic c. grammatical d. Gaddis: Starting Out with Python, 2e - Test Bank Chapter Two MULTIPLE CHOICE 1. What type of error produces incorrect results but does not prevent the program from running? a. syntax b. logic c. grammatical

More information

EC121 Mathematical Techniques A Revision Notes

EC121 Mathematical Techniques A Revision Notes EC Mathematical Techniques A Revision Notes EC Mathematical Techniques A Revision Notes Mathematical Techniques A begins with two weeks of intensive revision of basic arithmetic and algebra, to the level

More information

SECTION 3. ROUNDING, ESTIMATING, AND USING A CALCULATOR

SECTION 3. ROUNDING, ESTIMATING, AND USING A CALCULATOR SECTION 3. ROUNDING, ESTIMATING, AND USING A CALCULATOR Exact numbers are not always necessary or desirable. Sometimes it may be necessary to express the number which is a result of a calculation to a

More information

Solving Equations with Inverse Operations

Solving Equations with Inverse Operations Solving Equations with Inverse Operations Math 97 Supplement LEARNING OBJECTIVES 1. Solve equations by using inverse operations, including squares, square roots, cubes, and cube roots. The Definition of

More information

Introduction to Scientific Computing

Introduction to Scientific Computing Introduction to Scientific Computing Dr Hanno Rein Last updated: October 12, 2018 1 Computers A computer is a machine which can perform a set of calculations. The purpose of this course is to give you

More information

Chapter Overview. C++ Basics. Variables and Assignments. Variables and Assignments. Keywords. Identifiers. 2.1 Variables and Assignments

Chapter Overview. C++ Basics. Variables and Assignments. Variables and Assignments. Keywords. Identifiers. 2.1 Variables and Assignments Chapter 2 C++ Basics Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style Copyright 2011 Pearson Addison-Wesley. All rights

More information

Chapter 2 Working with Data Types and Operators

Chapter 2 Working with Data Types and Operators JavaScript, Fourth Edition 2-1 Chapter 2 Working with Data Types and Operators At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics

More information

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I BASIC COMPUTATION x public static void main(string [] args) Fundamentals of Computer Science I Outline Using Eclipse Data Types Variables Primitive and Class Data Types Expressions Declaration Assignment

More information

Intro. Scheme Basics. scm> 5 5. scm>

Intro. Scheme Basics. scm> 5 5. scm> Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if

More information

Chapter Two PROGRAMMING WITH NUMBERS AND STRINGS

Chapter Two PROGRAMMING WITH NUMBERS AND STRINGS Chapter Two PROGRAMMING WITH NUMBERS AND STRINGS Introduction Numbers and character strings are important data types in any Python program These are the fundamental building blocks we use to build more

More information

Rational Number is a number that can be written as a quotient of two integers. DECIMALS are special fractions whose denominators are powers of 10.

Rational Number is a number that can be written as a quotient of two integers. DECIMALS are special fractions whose denominators are powers of 10. PA Ch 5 Rational Expressions Rational Number is a number that can be written as a quotient of two integers. DECIMALS are special fractions whose denominators are powers of 0. Since decimals are special

More information

If Statements, For Loops, Functions

If Statements, For Loops, Functions Fundamentals of Programming If Statements, For Loops, Functions Table of Contents Hello World Types of Variables Integers and Floats String Boolean Relational Operators Lists Conditionals If and Else Statements

More information

Two Types of Types. Primitive Types in Java. Using Primitive Variables. Class #07: Java Primitives. Integer types.

Two Types of Types. Primitive Types in Java. Using Primitive Variables. Class #07: Java Primitives. Integer types. Class #07: Java Primitives Software Design I (CS 120): M. Allen, 13 Sep. 2018 Two Types of Types So far, we have mainly been dealing with objects, like DrawingGizmo, Window, Triangle, that are: 1. Specified

More information

Basic Data Types and Operators CS 8: Introduction to Computer Science, Winter 2019 Lecture #2

Basic Data Types and Operators CS 8: Introduction to Computer Science, Winter 2019 Lecture #2 Basic Data Types and Operators CS 8: Introduction to Computer Science, Winter 2019 Lecture #2 Ziad Matni, Ph.D. Dept. of Computer Science, UCSB Your Instructor Your instructor: Ziad Matni, Ph.D(zee-ahd

More information

Add Subtract Multiply Divide

Add Subtract Multiply Divide ARITHMETIC OPERATORS if AND if/else AND while LOOP Order of Operation (Precedence Part 1) Copyright 2014 Dan McElroy Add Subtract Multiply Divide + Add - Subtract * Multiply / Divide = gives the quotient

More information

Text Input and Conditionals

Text Input and Conditionals Text Input and Conditionals Text Input Many programs allow the user to enter information, like a username and password. Python makes taking input from the user seamless with a single line of code: input()

More information

Lesson Plan. Preparation

Lesson Plan. Preparation Math Practicum in Information Technology Lesson Plan Performance Objective Upon completion of this lesson, each student will be able to convert between different numbering systems and correctly write mathematical

More information

C++ Data Types. 1 Simple C++ Data Types 2. 3 Numeric Types Integers (whole numbers) Decimal Numbers... 5

C++ Data Types. 1 Simple C++ Data Types 2. 3 Numeric Types Integers (whole numbers) Decimal Numbers... 5 C++ Data Types Contents 1 Simple C++ Data Types 2 2 Quick Note About Representations 3 3 Numeric Types 4 3.1 Integers (whole numbers)............................................ 4 3.2 Decimal Numbers.................................................

More information

Programming Logic and Design Sixth Edition Chapter 2 Working with Data, Creating Modules, and Designing High-Quality Programs

Programming Logic and Design Sixth Edition Chapter 2 Working with Data, Creating Modules, and Designing High-Quality Programs Objectives Programming Logic and Design Sixth Edition Chapter 2 Working with Data, Creating Modules, and Designing High-Quality Programs In this chapter, you will learn about: Declaring and using variables

More information