St. Benedict s High School. Computing Science. Software Design & Development. (Part 1 Computer Programming) National 5

Size: px
Start display at page:

Download "St. Benedict s High School. Computing Science. Software Design & Development. (Part 1 Computer Programming) National 5"

Transcription

1 Computing Science Software Design & Development (Part 1 Computer Programming) National 5

2 VARIABLES & DATA TYPES Variables provide temporary storage for information that will be needed while a program is running. A programmer can imagine a variable as being a box into which information can be placed. When a programmer wants to store something, she or he gives a storage location a name and tells the computer what to put there. Using that name later (the name of the variable), you can get out (recall) the stored information at any time. For example, a program to calculate the area of a rectangle might use the following variables. When the program is running the data can be entered by the user and then stored, or it can be automatically calculated by the computer and then stored. The stored data may change every time the program is run, but the variable names remain the same. A programmer may have as many variables in a program as she or he needs. All that matters is that the variables have different names and use the correct data type. Data Types Data Type Examples Description Integer 3, 7, -2, -99, 54 holds positive and negative whole numbers Real 1.5, 3.14, holds any value in floating point includes decimal numbers and very large numbers. Visual Basic has several options for this including 'decimal', 'single' and 'double'. String Mary, joe, dog, stores data in ASCII - names, addresses and so on are string types. Boolean True, False uses just one bit in memory to store TRUE or FALSE. Before a variable can be used in a program it must be declared. Example 'variable declarations' in Visual Basic: Dim length as Integer Dim average as Decimal Dim firstname as String Dim correct as Boolean 2

3 One-Dimensional Arrays 1D arrays are data structures used to store a group of values or lists. All arrays hold data of the same data type so we can have string arrays or real arrays etc.. Each item of data is known as an element. Arithmetic can be performed still be performed on data held in arrays using +, -, *, /, ^. There are also operations for string arrays. Comparison of separate variables with an array 3

4 Arrays Typical examples of code used Consider the following data: 1 Homer 2 Marge 3 Bart 4 Lisa 5 Maggie Create an array. The code required to create the array could be something like this. Dim firstname(5) As String Note: we specify the name of the array, its size, and its data type. Store a single item of data. The code required to store Bart in element number 3 is firstname(3) = "bart" Display a single item of data. The code required to display the contents of element number 4 could be ListBox1.Items.Add(Firstname(4)) Get the idea? Now look at this 4

5 Display the entire array. The code required to display the entire list of all names can be easily written using a FOR loop as follows. Dim row As Integer For row = 1 To 5 ListBox1.Items.Add(firstname(row)) Next This code would be just as simple with a list of a million names! Store a list of user data. Rather than have all the names entered by the programmer when writing the code, we can also use a FOR loop to allow the user to enter their own names into the array. Dim person As Integer For person = 1 To 5 firstname(person) = InputBox("Enter a name") Next Prompt for, and display a single item of data. We can even retrieve individual items of information. Dim element As Integer element = InputBox("Enter a number between 1 and 5") MsgBox("You picked " & firstname(element)) 5

6 COMPUTATIONAL CONSTRUCTS Looping (Iteration) There are two types of loop: fixed and conditional. Fixed Loop (For Next) With a fixed loop you know exactly how many times something will be done. For instance a routine to enter 20 names into a program: DIM name$(20) FOR person = 1 TO 20 Input Please enter name :name$(person) NEXT person Conditional Loops (While Endwhile, Do... Until) With a conditional loop you do not know how many times the loop will be executed - it depends on a condition. You can have the condition at the beginning or the end. If the condition is checked at the beginning of the loop it is possible the loop will never be executed. If the condition is checked at the end of the loop then the loop will execute at least once. Here is a validation subroutine that checks the condition at the beginning. The program is taking in 20 marks in a test out of 100: Input number WHILE number < 0 OR number > 100 DO Input number ENDWHILE If the user keeps entering valid numbers like 56, 87, 23 etc. then the while loop above will never be executed. If they enter 105, then they will be asked to re-enter. If they keep entering such numbers then the loop will keep executing. We do not know how many times. 6

7 The condition can also be at the end of the loop meaning that the loop will be executed at least once. This simple example only accepts a number between 0 and 100, although it doesn t give an error message if it isn t. REPEAT Input mark UNTIL mark >= 0 AND mark <= 100 7

8 Complex Conditions AND, OR, NOT A "complex condition" contains two or more simple conditions linked by logic operators (AND, OR, NOT). They are frequently used in IF statements and some types of programming loops. Examples When might I wear shorts and a T-shirt? IF it is summer AND it is hot THEN I ll wear shorts and a T-shirt END IF Any other times? IF (it is summer AND it is hot) OR (it is winter AND I ve gone completely mad!) THEN I ll wear shorts and a T-shirt END IF Some example code dealing with test marks might require a complex condition like this If score1 > 50 AND score2 > 50 Then TextBox1.Text = "You passed both the tests." End If Our examples in the last section examples also use complex conditions Input number WHILE number < 0 OR number > 100 DO Input number ENDWHILE NOTE: The example above uses OR. This means that only one of the conditions need to be true for the code inside the loop to run repeatedly. REPEAT Input mark UNTIL mark >= 0 AND mark <= 100 NOTE: The example above uses AND. This means that both of the conditions need to be true for the code inside the loop to run repeatedly. NOT is often used in database and web searches Harry Potter AND book NOT film 8

9 Selection (IF THEN ELSE) A 'selection statement' tests if a condition is true or not and then does one thing or another. A simple example is adding 1 to a score if an answer is correct: IF answer = Paris THEN MsgBox( Well done ) Score = score + 1 ELSE MsgBox( No, Paris is the answer ) END IF When there are a number of alternatives, a big list of ELSE, ELSE, ELSE can be difficult to understand. Also even when one is true, the program still checks the remaining alternatives. Programming in this way is not pretty(!) and is very difficult to read. Look at the following horrible example: If mark>= 90 Then Listbox1.Items.Add("Grade A") Else If mark>= 80 Then Listbox1.Items.Add("Grade B") Else If mark>= 70 Then Listbox1.Items.Add("Grade C") Else If mark>= 60 Then Listbox1.Items.Add("Grade D") Else Listbox1.Items.Add("Fail") End If End If End If End If It's horrible!!! You should try to avoid this in your own code. So multi IF.. THEN.. ELSEs are inefficient and make a program less readable (and so less maintainable). (NOTE: An IF statement coded entirely inside another IF statement is called a 'nested IF'.) 9

10 Multiple Selection (CASE) When there are many possible outcomes, the IF method of selection becomes cumbersome. All those ELSE s make a program difficult to understand. As an alternative there is the CASE statement: Based upon a variable called mark, this code displays the appropriate Grade. CASE mark OF WHEN >=70 Listbox1.Items.Add( Grade A ) WHEN >=60 Listbox1.Items.Add( Grade B ) WHEN >=50 Listbox1.Items.Add( Grade C ) WHEN >=45 Listbox1.Items.Add( Grade D ) OTHERWISE Listbox1.Items.Add( Fail ) END CASE Note that if the mark was 90, the first case would be true and the program would skip the rest (unlike ELSEs where it would check every condition). 10

11 String Functions Arithmetic can be performed on numeric variables using +, -, *, / etc. There are also operations for string variables. String Concatenation When you use '&' (or '+' depending on the programming language) it joins two strings together. This is called concatenation. E.g. wholename = firstname & " " & surname Other String Operations You can also extract part of a string - a substring. Where name="scotland" LEN(name) LCASE(name) UCASE(name) LEFT(name,2) RIGHT(name,3) MID(name,2,3) MID(name,4,2) RESULT => 8 scotland SCOTLAND Sc and cot tl Note: Len gives you how many characters are in the string. Lcase and Ucase give lower or upper case letters. Right (name,3) gives the last 3 characters. Left(name,2) gives the first 2 Mid(name,2,3) means start at position 2 and give the next 3 characters. 11

12 Pre-defined Functions A pre-defined function is a piece of pre-written code that is actually part of the programming language. Many programming languages will actually have a library of these pre-defined functions, each of which is designed to perform a frequently needed task for the programmer. Here are a few useful Visual Basic pre-defined functions: Function Example Code Description Val Int number = Val("2457") 'sets number to number = Val(" ") 'sets number to 2457 number = Val("24 and 57") 'sets number to 24. number = Val(InputBox("Enter a number")) converts an empty inputbox value to 0. MyNumber = Int(99.8) ' Returns 99. MyNumber = Int(-99.8) ' Returns MyNumber = Int(-99.2) ' Returns The Val function actually returns the numbers contained in the data. Val stops converting at the first character that cannot be interpreted as a numeric digit or white space. It is particularly useful for converting empty textboxes to the value 0 in order to avoid program crashes. The Int function returns integer portions of numbers. In the case of a negative number, the Int function returns the first negative integer less than or equal to the number Math.Round mynumber = Math.Round(4.3) ' Returns 4. mynumber = Math.Round(4.4) ' Returns 4. mynumber = Math.Round(4.5) ' Returns 4. mynumber = Math.Round(4.6) ' Returns 5. mynumber = Math.Round(3.14, 1) ' Returns 3.1 The Math.Round function rounds a value to the nearest integer or to the specified number of decimal digits depending on the data type used. Very useful for calculations involving money. UCase City = InputBox("Enter capital city of France...") If UCase(City) = "PARIS" Then Correct = Correct + 1 Else MsgBox("Wrong!") End If UCase converts lowercase letters to uppercase. Very useful for text comparisons (e.g. quiz programs) where a match is required but, the programmer cannot anticipate the exact use of capital letters made by the user. 12

13 TESTING AND DOCUMENTING SOLUTIONS Program Testing Once a program has been written, there then follows the testing stage. The most crucial aspect is to test that the program does what it is supposed to do and does not crash. Test Data A programmer should create sets of test data to feed the software to find out how it behaves. Here are some of the important points about making up such sets: The expected results from a test data set must be known in advance, so that they can be checked against the actual results. One set should test normal operation of the software, to make sure that there are no unexpected results in ordinary use. One set should test the operation extremes of the software, to make sure that the boundary conditions are handled properly. One set should test exceptions to the normal operating conditions. This set will show whether or not the software can react to unexpected inputs in an effective way, without crashing. 13

14 Testing must be systematic and comprehensive. It is systematic when you plan a table of test data with expected outcomes and then test the program with that data. It is comprehensive when you test as many eventualities as possible. For example if you were testing a program that took in marks out of 100 in a test you must test: Normal Data (valid data) Test Data Expected Result Actual Result Comment 45 Data accepted As expected. Program appears OK 78 Data accepted As expected. Program appears OK 26 Data accepted As expected. Program appears OK Extreme (data on the boundary of being acceptable) Test Data Expected Result Actual Result Comment 0 Data accepted As expected Program ppears OK 100 Data accepted As expected Program appears OK Exceptions (data that should not be acceptable) Test Data Expected Result Actual Result Comment -5 Not Accepted Not Accepted Prompt to re-enter 109 Not Accepted Accepted Prompt to re-enter Not Accepted Not Accepted Program continues!!! Five Not accepted Not Accepted Program crash!!! x Not accepted Not accepted Program crash!!! 14

15 ERROR TYPES There are three main types of error in a program: LOGIC ERROR when the program doesn t crash, but doesn t do what it is supposed to do. e.g. IF age < 18 THEN display You can vote SYNTAX ERROR where the program won t work because of a mistake in the code (usually a typing mistake). e.g. Listbox1.Items.Add( Hello) RUN-TIME ERROR when the program crashes because of a fault e.g. Division by zero: Average = total / howmany and howmany has the value 0 Note: Division by zero is impossible! Seriously! Think about it... 15

16 READABILITY There are several factors which can affect a program s readability. Meaningful Variable Names This makes a program more readable and easier to understand. It is therefore easier for a programmer who has to make changes in the future to understand the code. Internal Commentary Internal commentary explains what each section of the code does. Again, this makes it easier for a programmer who has to make changes in the future to understand the code. Structured Listing When a listing is structured it provides good visual cues to the programmer about the purpose of sections of code. For example, Indenting loops and selection (IF) structures and lower case for variables all help make a program more readable. Modularity A problem should be broken down into smaller sub-problems. Each sub-problem can be thought of as a single module. Good modularity allows sections of the program to be altered without breaking other parts of the program. 16

17 Readability - Example of Good Practice The example below shows meaningful variable names and internal commentary. The indentation of code and use of white space also makes the structure easy to follow. Sub find_max() 'age example Dim max As Integer ' highest value Dim position As Integer ' element number in array with highest value max = age(1) ' make first value in array initial highest position = 1 ' record position of highest so far For row = 1 To 5 Next If age(row) > max Then ' a new maximum value has been found End If max = age(row) ' assign new value to maximum position = row ' update position of maximum found ListBox1.Items.Add("The oldest age is " & max) ListBox1.Items.Add("The oldest person is " & name(position)) End Sub 17

18 Readability - Example of Bad Practice The code below does exactly the same as the code above. Unfortunately there are no meaningful variable names, comments, and no indentation to show the structure. There isn't even any colour. Can you read it and understand it? Sub find_max() Dim a As Integer Dim b As Integer a = c(1) b = 1 < For x = 1 To 5 If c(x)> a Then a = c(x) b = x End If Next ListBox1.Items.Add("The oldest age is " & a) ListBox1.Items.Add("The oldest person is " & d(b)) End Sub 18

19 ALGORITHM SPECIFICATION Input Validation Input validation is commonly used to ensure that a number lies within an acceptable range of values. E.g. acceptable exam score data should be between 0 and 100 inclusive. Data outwith this range should be rejected and the user should be prompted to enter the data again. This should continue until an acceptable score is entered by the user. DESIGN: 1. Take in value 2. While value not in range 3. Ask to re-enter 4. Take in value 5. End while CODE: number = InputBox("Please enter a number between 0 and 100 While number <= 0 Or number >= 100 End While MsgBox("Please enter a number between 0 and 100",, "Error!") number = InputBox("Please enter a number between 0 and 100 ") 19

20 Linear Search To find a particular item of data in an array... DESIGN 1. Take in target 2. For each item in list 3. If target = item then 4. Report found 5. Report position 6. End if 7. Next value CODE Dim target As String 'name to be found Dim found As Boolean = False Dim found_location As Integer target = InputBox( "Enter name to be found...") For row = 1 To 5 Next If target = name(row) Then End If found = True found_location = row 'take note of element number of found item [NOTE: Code like the following could then be used after the standard algorithm:] If found = True Then ListBox1.Items.Add(target & is & age(found_location) & years old. ) Else ListBox1.Items.Add( "Not found!") End If 20

21 Find Max/Min Finding the largest or smallest value in a list of numbers held in a one-dimensional array. FIND MAX DESIGN 1. Set max to first value 2. For each other value in list 3. If the value > max then 4. Set max to that value 5. End if 6. Next value 7. Display max CODE Sub find_max() 'age example Dim max As Integer ' highest value max = age(1) ' make first value in array initial highest For row = 1 To 5 Next End Sub If age(row) > max Then ' a new maximum value has been found max = age(row) ' assign new value to maximum End If ListBox1.Items.Add("The oldest age is " & max) 21

22 FIND MIN DESIGN 1. Set min to first value 2. For each other value in list 3. If the value < min then 4. Set min to that value 5. End if 6. Next value 7. Display min CODE Sub find_min() 'age example Dim min As Integer ' smallest value min = age(1) ' make first value in array initial smallest For row = 1 To 5 Next If age(row) < min Then ' a new smallest value has been found max = age(row) ' assign new value to smallest End If ListBox1.Items.Add("The youngest age is " & min) End Sub 22

23 Count Occurrences To count certain items of data in an array... DESIGN 1. Set count to zero 2. Take in target 3. For each item in list 4. If target = item then 5. add 1 to count 6. End if 7. Next value 8. Display count CODE Dim count As Integer count = 0 target = InputBox( "Enter age to be found...") For row = 1 To 5 If age(row) = target Then count = count + 1 ' incremenent count End If Next ListBox1.Items.Add("There are " & count & " records matching your search.") 23

24 DESIGN NOTATIONS Once the needs of the user are clearly understood and documented, software development can move onto the next stage, involving the DESIGN of the system. We are now moving from asking what needs to be done to asking how are we going to do it. We need to use a structured and methodical approach to the planning of our solution. Top Down Design A top-down approach to design allows us to think simply about the overall task to be done and then split the task up into smaller, more manageable sub-problems. This is sometimes called stepwise-refinement. The structured design approach of stepwise refinement also allows you to manage a very large project, by sub-dividing it into modules or subroutines. Each module can be further refined, producing a hierarchical structure. These structures are much simpler to develop, to understand and to maintain. The important point is that there must be some documented evidence of this stage of the design. It is far easier to correct logical mistakes, or to upgrade a piece of software, by using the structure charts or pseudocode listings, than by referring to the actual program code, because the structure charts or pseudocode listings make it easier to understand how the software was built in the first place. 24

25 Pseudocode Pseudocode is an outline of a program, written in a form that can easily be converted into real programming statements. Here are some examples of Pseudocode: Calculate the area of a rectangle TOP LEVEL 1. Get sizes 2. Calculate area 3. Display area REFINEMENTS 1.1 Get length from keyboard 1.2 Get breadth from keyboard 2.1 Set Area to length * breadth 3.1 Clear screen 3.2 Set text colour to blue 3.3 Send message and answer to screen Calculate the area of 5 rectangles (notice only the top level changes from above) TOP LEVEL 1. Do 5 times 2. Get sizes 3. Calculate area 4. Display area 5. End loop REFINEMENTS 1.1 Get length from keyboard 1.2 Get breadth from keyboard 2.1 Set Area to length * breadth 3.1 Clear screen 3.2 Set text colour to blue 3.3 Send message and answer to screen 25

26 A quiz question: 1. Ask question 2. Get answer 3. IF answer correct THEN 4. display well done message 5. ELSE 6. display fail message and correct answer 7. END IF 26

27 Structure Diagrams / Flowcharts The examples here represent structure diagrams of the same programs shown in the pseduocode page for comparison. Calculate the area of a rectangle Calculate the area of 5 rectangles 27

28 A quiz question: 28

Higher Computing Science Software Design and Development - Programming Summary Notes

Higher Computing Science Software Design and Development - Programming Summary Notes Higher Computing Science Software Design and Development - Programming Summary Notes Design notations A design notation is the method we use to write down our program design. Pseudocode is written using

More information

Variables and Data Representation

Variables and Data Representation You will recall that a computer program is a set of instructions that tell a computer how to transform a given set of input into a specific output. Any program, procedural, event driven or object oriented

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

Definition: A data structure is a way of organizing data in a computer so that it can be used efficiently.

Definition: A data structure is a way of organizing data in a computer so that it can be used efficiently. The Science of Computing I Lesson 4: Introduction to Data Structures Living with Cyber Pillar: Data Structures The need for data structures The algorithms we design to solve problems rarely do so without

More information

CS 115 Lecture 4. More Python; testing software. Neil Moore

CS 115 Lecture 4. More Python; testing software. Neil Moore CS 115 Lecture 4 More Python; testing software Neil Moore Department of Computer Science University of Kentucky Lexington, Kentucky 40506 neil@cs.uky.edu 8 September 2015 Syntax: Statements A statement

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

Programming with Visual Studio Higher (v. 2013)

Programming with Visual Studio Higher (v. 2013) Programming with Visual Studio Higher (v. 2013) Contents/Requirements Checklist Multiple selection: using ifs & case While Loops Using arrays Filling arrays Displaying array contents Types of variables:

More information

CS112 Lecture: Repetition Statements

CS112 Lecture: Repetition Statements CS112 Lecture: Repetition Statements Objectives: Last revised 2/18/05 1. To explain the general form of the java while loop 2. To introduce and motivate the java do.. while loop 3. To explain the general

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

TABLE OF CONTENTS 2 CHAPTER 1 3 CHAPTER 2 4 CHAPTER 3 5 CHAPTER 4. Algorithm Design & Problem Solving. Data Representation.

TABLE OF CONTENTS 2 CHAPTER 1 3 CHAPTER 2 4 CHAPTER 3 5 CHAPTER 4. Algorithm Design & Problem Solving. Data Representation. 2 CHAPTER 1 Algorithm Design & Problem Solving 3 CHAPTER 2 Data Representation 4 CHAPTER 3 Programming 5 CHAPTER 4 Software Development TABLE OF CONTENTS 1. ALGORITHM DESIGN & PROBLEM-SOLVING Algorithm:

More information

Chapter 2.6: Testing and running a solution

Chapter 2.6: Testing and running a solution Chapter 2.6: Testing and running a solution 2.6 (a) Types of Programming Errors When programs are being written it is not surprising that mistakes are made, after all they are very complicated. There are

More information

CS 115 Lecture 8. Selection: the if statement. Neil Moore

CS 115 Lecture 8. Selection: the if statement. Neil Moore CS 115 Lecture 8 Selection: the if statement Neil Moore Department of Computer Science University of Kentucky Lexington, Kentucky 40506 neil@cs.uky.edu 24 September 2015 Selection Sometime we want to execute

More information

Scheme of work Cambridge International AS & A Level Computing (9691)

Scheme of work Cambridge International AS & A Level Computing (9691) Scheme of work Cambridge International AS & A Level Computing (9691) Unit 2: Practical programming techniques Recommended prior knowledge Students beginning this course are not expected to have studied

More information

Variables and Constants

Variables and Constants HOUR 3 Variables and Constants Programs need a way to store the data they use. Variables and constants offer various ways to work with numbers and other values. In this hour you learn: How to declare and

More information

Statistics Case Study 2000 M. J. Clancy and M. C. Linn

Statistics Case Study 2000 M. J. Clancy and M. C. Linn Statistics Case Study 2000 M. J. Clancy and M. C. Linn Problem Write and test functions to compute the following statistics for a nonempty list of numeric values: The mean, or average value, is computed

More information

Chapter 4: Making Decisions

Chapter 4: Making Decisions Chapter 4: Making Decisions 4.1 Relational Operators Relational Operators Used to compare numbers to determine relative order Operators: > Greater than < Less than >= Greater than or equal to

More information

CS112 Lecture: Loops

CS112 Lecture: Loops CS112 Lecture: Loops Objectives: Last revised 3/11/08 1. To introduce some while loop patterns 2. To introduce and motivate the java do.. while loop 3. To review the general form of the java for loop.

More information

Higher Computing Science. Software Design and Development

Higher Computing Science. Software Design and Development Higher Computing Science Software Design and Development Programming with Visual Studio 2012 1 CONTENTS Topic 1 Topic 2 Topic 3 Topic 4 Topic 5 Topic 6 Topic 7 Topic 8 Topic 9 Getting started Strings and

More information

Chapter 4: Making Decisions

Chapter 4: Making Decisions Chapter 4: Making Decisions CSE 142 - Computer Programming I 1 4.1 Relational Operators Relational Operators Used to compare numbers to determine relative order Operators: > Greater than < Less than >=

More information

VISUAL BASIC 6.0 OVERVIEW

VISUAL BASIC 6.0 OVERVIEW VISUAL BASIC 6.0 OVERVIEW GENERAL CONCEPTS Visual Basic is a visual programming language. You create forms and controls by drawing on the screen rather than by coding as in traditional languages. Visual

More information

Chapter 5. Repetition. Contents. Introduction. Three Types of Program Control. Two Types of Repetition. Three Syntax Structures for Looping in C++

Chapter 5. Repetition. Contents. Introduction. Three Types of Program Control. Two Types of Repetition. Three Syntax Structures for Looping in C++ Repetition Contents 1 Repetition 1.1 Introduction 1.2 Three Types of Program Control Chapter 5 Introduction 1.3 Two Types of Repetition 1.4 Three Structures for Looping in C++ 1.5 The while Control Structure

More information

LECTURE 04 MAKING DECISIONS

LECTURE 04 MAKING DECISIONS PowerPoint Slides adapted from *Starting Out with C++: From Control Structures through Objects, 7/E* by *Tony Gaddis* Copyright 2012 Pearson Education Inc. COMPUTER PROGRAMMING LECTURE 04 MAKING DECISIONS

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

Control Flow. COMS W1007 Introduction to Computer Science. Christopher Conway 3 June 2003

Control Flow. COMS W1007 Introduction to Computer Science. Christopher Conway 3 June 2003 Control Flow COMS W1007 Introduction to Computer Science Christopher Conway 3 June 2003 Overflow from Last Time: Why Types? Assembly code is typeless. You can take any 32 bits in memory, say this is an

More information

Course Outline. Introduction to java

Course Outline. Introduction to java Course Outline 1. Introduction to OO programming 2. Language Basics Syntax and Semantics 3. Algorithms, stepwise refinements. 4. Quiz/Assignment ( 5. Repetitions (for loops) 6. Writing simple classes 7.

More information

Chapter 2.4: Common facilities of procedural languages

Chapter 2.4: Common facilities of procedural languages Chapter 2.4: Common facilities of procedural languages 2.4 (a) Understand and use assignment statements. Assignment An assignment is an instruction in a program that places a value into a specified variable.

More information

Programming. We will be introducing various new elements of Python and using them to solve increasingly interesting and complex problems.

Programming. We will be introducing various new elements of Python and using them to solve increasingly interesting and complex problems. Plan for the rest of the semester: Programming We will be introducing various new elements of Python and using them to solve increasingly interesting and complex problems. We saw earlier that computers

More information

Repetition Through Recursion

Repetition Through Recursion Fundamentals of Computer Science I (CS151.02 2007S) Repetition Through Recursion Summary: In many algorithms, you want to do things again and again and again. For example, you might want to do something

More information

printf( Please enter another number: ); scanf( %d, &num2);

printf( Please enter another number: ); scanf( %d, &num2); CIT 593 Intro to Computer Systems Lecture #13 (11/1/12) Now that we've looked at how an assembly language program runs on a computer, we're ready to move up a level and start working with more powerful

More information

Python allows variables to hold string values, just like any other type (Boolean, int, float). So, the following assignment statements are valid:

Python allows variables to hold string values, just like any other type (Boolean, int, float). So, the following assignment statements are valid: 1 STRINGS Objectives: How text data is internally represented as a string Accessing individual characters by a positive or negative index String slices Operations on strings: concatenation, comparison,

More information

MPATE-GE 2618: C Programming for Music Technology. Unit 4.2

MPATE-GE 2618: C Programming for Music Technology. Unit 4.2 MPATE-GE 2618: C Programming for Music Technology Unit 4.2 Quiz 1 results (out of 25) Mean: 19.9, (standard deviation = 3.9) Equivalent to 79.1% (SD = 15.6) Median: 21.5 High score: 24 Low score: 13 Pointer

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

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

Mobile Computing Professor Pushpendra Singh Indraprastha Institute of Information Technology Delhi Java Basics Lecture 02

Mobile Computing Professor Pushpendra Singh Indraprastha Institute of Information Technology Delhi Java Basics Lecture 02 Mobile Computing Professor Pushpendra Singh Indraprastha Institute of Information Technology Delhi Java Basics Lecture 02 Hello, in this lecture we will learn about some fundamentals concepts of java.

More information

IT 374 C# and Applications/ IT695 C# Data Structures

IT 374 C# and Applications/ IT695 C# Data Structures IT 374 C# and Applications/ IT695 C# Data Structures Module 2.1: Introduction to C# App Programming Xianrong (Shawn) Zheng Spring 2017 1 Outline Introduction Creating a Simple App String Interpolation

More information

Language Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */

Language Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */ Overview Language Basics This chapter describes the basic elements of Rexx. It discusses the simple components that make up the language. These include script structure, elements of the language, operators,

More information

Outline. Program development cycle. Algorithms development and representation. Examples.

Outline. Program development cycle. Algorithms development and representation. Examples. Outline Program development cycle. Algorithms development and representation. Examples. 1 Program Development Cycle Program development cycle steps: Problem definition. Problem analysis (understanding).

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

CSE 1223: Introduction to Computer Programming in Java Chapter 3 Branching

CSE 1223: Introduction to Computer Programming in Java Chapter 3 Branching CSE 1223: Introduction to Computer Programming in Java Chapter 3 Branching 1 Flow of Control The order in which statements in a program are executed is called the flow of control So far we have only seen

More information

1. What is the minimum number of bits needed to store a single piece of data representing: a. An integer between 0 and 100?

1. What is the minimum number of bits needed to store a single piece of data representing: a. An integer between 0 and 100? 1 CS 105 Review Questions Most of these questions appeared on past exams. 1. What is the minimum number of bits needed to store a single piece of data representing: a. An integer between 0 and 100? b.

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

Program Planning, Data Comparisons, Strings

Program Planning, Data Comparisons, Strings Program Planning, Data Comparisons, Strings Program Planning Data Comparisons Strings Reading for this class: Dawson, Chapter 3 (p. 80 to end) and 4 Program Planning When you write your first programs,

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

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

Outline. Data and Operations. Data Types. Integral Types

Outline. Data and Operations. Data Types. Integral Types Outline Data and Operations Data Types Arithmetic Operations Strings Variables Declaration Statements Named Constant Assignment Statements Intrinsic (Built-in) Functions Data and Operations Data and Operations

More information

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0. L J Howell UX Software Ver. 1.0

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0. L J Howell UX Software Ver. 1.0 VISUAL GUIDE to RX Scripting for Roulette Xtreme - System Designer 2.0 L J Howell UX Software 2009 Ver. 1.0 TABLE OF CONTENTS INTRODUCTION...ii What is this book about?... iii How to use this book... iii

More information

CS Summer 2013

CS Summer 2013 CS 1110 - Summer 2013 intro to programming -- how to think like a robot :) we use the Python* language (www.python.org) programming environments (many choices): Eclipse (free from www.eclipse.org), or

More information

The Big Python Guide

The Big Python Guide The Big Python Guide Big Python Guide - Page 1 Contents Input, Output and Variables........ 3 Selection (if...then)......... 4 Iteration (for loops)......... 5 Iteration (while loops)........ 6 String

More information

Ex: If you use a program to record sales, you will want to remember data:

Ex: If you use a program to record sales, you will want to remember data: Data Variables Programs need to remember values. Ex: If you use a program to record sales, you will want to remember data: A loaf of bread was sold to Sione Latu on 14/02/19 for T$1.00. Customer Name:

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

Programming with Python

Programming with Python Programming with Python Dr Ben Dudson Department of Physics, University of York 21st January 2011 http://www-users.york.ac.uk/ bd512/teaching.shtml Dr Ben Dudson Introduction to Programming - Lecture 2

More information

UNIVERSITY OF CALIFORNIA, SANTA CRUZ BOARD OF STUDIES IN COMPUTER ENGINEERING

UNIVERSITY OF CALIFORNIA, SANTA CRUZ BOARD OF STUDIES IN COMPUTER ENGINEERING UNIVERSITY OF CALIFORNIA, SANTA CRUZ BOARD OF STUDIES IN COMPUTER ENGINEERING CMPE13/L: INTRODUCTION TO PROGRAMMING IN C SPRING 2012 Lab 3 Matrix Math Introduction Reading In this lab you will write a

More information

CMSC 201 Fall 2018 Lab 04 While Loops

CMSC 201 Fall 2018 Lab 04 While Loops CMSC 201 Fall 2018 Lab 04 While Loops Assignment: Lab 04 While Loops Due Date: During discussion, September 24 th through September 27 th Value: 10 points (8 points during lab, 2 points for Pre Lab quiz)

More information

Testing is a very big and important topic when it comes to software development. Testing has a number of aspects that need to be considered.

Testing is a very big and important topic when it comes to software development. Testing has a number of aspects that need to be considered. Testing Testing is a very big and important topic when it comes to software development. Testing has a number of aspects that need to be considered. System stability is the system going to crash or not?

More information

C++ Programming Language Lecture 2 Problem Analysis and Solution Representation

C++ Programming Language Lecture 2 Problem Analysis and Solution Representation C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department Program Development Cycle Program development

More information

STUDENT LESSON A12 Iterations

STUDENT LESSON A12 Iterations STUDENT LESSON A12 Iterations Java Curriculum for AP Computer Science, Student Lesson A12 1 STUDENT LESSON A12 Iterations INTRODUCTION: Solving problems on a computer very often requires a repetition of

More information

Higher Software Development - Section 1a

Higher Software Development - Section 1a Higher Software Development - Section 1a _ 1. List the stages involved in the development of a program in the correct order? (7) 2. In the software development process, what happens at the analysis stage?

More information

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals 1 Recall From Last Time: Java Program import java.util.scanner; public class EggBasketEnhanced { public static void main(string[]

More information

National 5 Computing Science Software Design & Development

National 5 Computing Science Software Design & Development National 5 Computing Science Software Design & Development 1 Stages of Development 2 Analysis 3 Design 4 Implementation 5 Testing 6 Documentation 7 Evaluation 8 Maintenance 9 Data Types & Structures 10

More information

Chapter 3 Structured Program Development

Chapter 3 Structured Program Development 1 Chapter 3 Structured Program Development Copyright 2007 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 3 - Structured Program Development Outline 3.1 Introduction

More information

Selection Control Structure CSC128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING

Selection Control Structure CSC128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING Selection Control Structure CSC128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING MULTIPLE SELECTION To solve a problem that has several selection, use either of the following method: Multiple selection nested

More information

Introduction to String Manipulation

Introduction to String Manipulation Introduction to Computer Programming Introduction to String Manipulation CSCI-UA.0002 What is a String? A String is a data type in the Python programming language A String can be described as a "sequence

More information

Announcements. Lab Friday, 1-2:30 and 3-4:30 in Boot your laptop and start Forte, if you brought your laptop

Announcements. Lab Friday, 1-2:30 and 3-4:30 in Boot your laptop and start Forte, if you brought your laptop Announcements Lab Friday, 1-2:30 and 3-4:30 in 26-152 Boot your laptop and start Forte, if you brought your laptop Create an empty file called Lecture4 and create an empty main() method in a class: 1.00

More information

Compilation and Execution Simplifying Fractions. Loops If Statements. Variables Operations Using Functions Errors

Compilation and Execution Simplifying Fractions. Loops If Statements. Variables Operations Using Functions Errors First Program Compilation and Execution Simplifying Fractions Loops If Statements Variables Operations Using Functions Errors C++ programs consist of a series of instructions written in using the C++ syntax

More information

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals

More information

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal Lesson Goals Understand Control Structures Understand how to control the flow of a program

More information

Objectives. Chapter 4: Control Structures I (Selection) Objectives (cont d.) Control Structures. Control Structures (cont d.) Relational Operators

Objectives. Chapter 4: Control Structures I (Selection) Objectives (cont d.) Control Structures. Control Structures (cont d.) Relational Operators Objectives Chapter 4: Control Structures I (Selection) In this chapter, you will: Learn about control structures Examine relational and logical operators Explore how to form and evaluate logical (Boolean)

More information

Excerpt from "Art of Problem Solving Volume 1: the Basics" 2014 AoPS Inc.

Excerpt from Art of Problem Solving Volume 1: the Basics 2014 AoPS Inc. Chapter 5 Using the Integers In spite of their being a rather restricted class of numbers, the integers have a lot of interesting properties and uses. Math which involves the properties of integers is

More information

Discussion 1H Notes (Week 3, April 14) TA: Brian Choi Section Webpage:

Discussion 1H Notes (Week 3, April 14) TA: Brian Choi Section Webpage: Discussion 1H Notes (Week 3, April 14) TA: Brian Choi (schoi@cs.ucla.edu) Section Webpage: http://www.cs.ucla.edu/~schoi/cs31 More on Arithmetic Expressions The following two are equivalent:! x = x + 5;

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

Pseudocode syntax, descriptions and examples

Pseudocode syntax, descriptions and examples Pseudocode syntax, descriptions and examples Overview: This table provides a reference for commonly used pseudocode for introductory computer program design courses. You should use this as your reference

More information

Chapter 4: Making Decisions. Copyright 2012 Pearson Education, Inc. Sunday, September 7, 14

Chapter 4: Making Decisions. Copyright 2012 Pearson Education, Inc. Sunday, September 7, 14 Chapter 4: Making Decisions 4.1 Relational Operators Relational Operators Used to compare numbers to determine relative order Operators: > Greater than < Less than >= Greater than or equal to

More information

Introduction to Decision Structures. Boolean & If Statements. Different Types of Decisions. Boolean Logic. Relational Operators

Introduction to Decision Structures. Boolean & If Statements. Different Types of Decisions. Boolean Logic. Relational Operators Boolean & If Statements Introduction to Decision Structures Chapter 4 Fall 2015, CSUS Chapter 4.1 Introduction to Decision Structures Different Types of Decisions A decision structure allows a program

More information

CS 142 Style Guide Grading and Details

CS 142 Style Guide Grading and Details CS 142 Style Guide Grading and Details In the English language, there are many different ways to convey a message or idea: some ways are acceptable, whereas others are not. Similarly, there are acceptable

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

Algorithms and Flowcharts

Algorithms and Flowcharts UNIT 2 Chapter 1 Algorithms and Flowcharts After studying this lesson, the students will be able to understand the need of Algorithm and Flowcharts; solve problems by using algorithms and flowcharts; get

More information

Making Decisions In Python

Making Decisions In Python Making Decisions In Python In this section of notes you will learn how to have your programs choose between alternative courses of action. Decision Making Is All About Choices My next vacation? Images:

More information

Chapter 4: Control Structures I (Selection) Objectives. Objectives (cont d.) Control Structures. Control Structures (cont d.

Chapter 4: Control Structures I (Selection) Objectives. Objectives (cont d.) Control Structures. Control Structures (cont d. Chapter 4: Control Structures I (Selection) In this chapter, you will: Objectives Learn about control structures Examine relational and logical operators Explore how to form and evaluate logical (Boolean)

More information

Midterm Exam 2B Answer key

Midterm Exam 2B Answer key Midterm Exam 2B Answer key 15110 Principles of Computing Fall 2015 April 6, 2015 Name: Andrew ID: Lab section: Instructions Answer each question neatly in the space provided. There are 6 questions totaling

More information

Control Structures in Java if-else and switch

Control Structures in Java if-else and switch Control Structures in Java if-else and switch Lecture 4 CGS 3416 Spring 2017 January 23, 2017 Lecture 4CGS 3416 Spring 2017 Selection January 23, 2017 1 / 26 Control Flow Control flow refers to the specification

More information

1 ICS 161: Design and Analysis of Algorithms Lecture notes for January 23, Bucket Sorting

1 ICS 161: Design and Analysis of Algorithms Lecture notes for January 23, Bucket Sorting 1 ICS 161: Design and Analysis of Algorithms Lecture notes for January 23, 1996 2 Bucket Sorting We ve seen various algorithms for sorting in O(n log n) time and a lower bound showing that O(n log n) is

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

Notes on Chapter 1 Variables and String

Notes on Chapter 1 Variables and String Notes on Chapter 1 Variables and String Note 0: There are two things in Python; variables which can hold data and the data itself. The data itself consists of different kinds of data. These include numbers,

More information

Numbers and Computers. Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras

Numbers and Computers. Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras Numbers and Computers Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras 1 Think of a number between 1 and 15 8 9 10 11 12 13 14 15 4 5 6 7 12 13 14 15 2 3 6 7 10 11 14 15

More information

Python The way of a program. Srinidhi H Asst Professor Dept of CSE, MSRIT

Python The way of a program. Srinidhi H Asst Professor Dept of CSE, MSRIT Python The way of a program Srinidhi H Asst Professor Dept of CSE, MSRIT 1 Problem Solving Problem solving means the ability to formulate problems, think creatively about solutions, and express a solution

More information

3 The L oop Control Structure

3 The L oop Control Structure 3 The L oop Control Structure Loops The while Loop Tips and Traps More Operators The for Loop Nesting of Loops Multiple Initialisations in the for Loop The Odd Loop The break Statement The continue Statement

More information

Lecture 10: for, do, and switch

Lecture 10: for, do, and switch Lecture 10: for, do, and switch Jiajia Liu Recall the while Loop The while loop has the general form while ( boolean condition ) { The while loop is like a repeated if statement. It will repeat the statements

More information

Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller

Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller Table of Contents Introduction!... 1 Part 1: Entering Data!... 2 1.a: Typing!... 2 1.b: Editing

More information

Problem Solving for Intro to Computer Science

Problem Solving for Intro to Computer Science Problem Solving for Intro to Computer Science The purpose of this document is to review some principles for problem solving that are relevant to Intro to Computer Science course. Introduction: A Sample

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

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Spring 2016 Howard Rosenthal

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Spring 2016 Howard Rosenthal Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Spring 2016 Howard Rosenthal Lesson Goals Understand Control Structures Understand how to control the flow of a program

More information

Language Fundamentals

Language Fundamentals Language Fundamentals VBA Concepts Sept. 2013 CEE 3804 Faculty Language Fundamentals 1. Statements 2. Data Types 3. Variables and Constants 4. Functions 5. Subroutines Data Types 1. Numeric Integer Long

More information

Variable A variable is a value that can change during the execution of a program.

Variable A variable is a value that can change during the execution of a program. Declare and use variables and constants Variable A variable is a value that can change during the execution of a program. Constant A constant is a value that is set when the program initializes and does

More information

PDS Lab Section 16 Autumn Tutorial 3. C Programming Constructs

PDS Lab Section 16 Autumn Tutorial 3. C Programming Constructs PDS Lab Section 16 Autumn-2017 Tutorial 3 C Programming Constructs This flowchart shows how to find the roots of a Quadratic equation Ax 2 +Bx+C = 0 Start Input A,B,C x B 2 4AC False x If 0 True B x 2A

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

You will have mastered the material in this chapter when you can:

You will have mastered the material in this chapter when you can: CHAPTER 6 Loop Structures OBJECTIVES You will have mastered the material in this chapter when you can: Add a MenuStrip object Use the InputBox function Display data using the ListBox object Understand

More information

Program Development. Java Program Statements. Design. Requirements. Testing. Implementation

Program Development. Java Program Statements. Design. Requirements. Testing. Implementation Program Development Java Program Statements Selim Aksoy Bilkent University Department of Computer Engineering saksoy@cs.bilkent.edu.tr The creation of software involves four basic activities: establishing

More information

Chapter 5 Errors. Bjarne Stroustrup

Chapter 5 Errors. Bjarne Stroustrup Chapter 5 Errors Bjarne Stroustrup www.stroustrup.com/programming Abstract When we program, we have to deal with errors. Our most basic aim is correctness, but we must deal with incomplete problem specifications,

More information

School of Computer Science CPS109 Course Notes 5 Alexander Ferworn Updated Fall 15

School of Computer Science CPS109 Course Notes 5 Alexander Ferworn Updated Fall 15 Table of Contents 1 INTRODUCTION... 1 2 IF... 1 2.1 BOOLEAN EXPRESSIONS... 3 2.2 BLOCKS... 3 2.3 IF-ELSE... 4 2.4 NESTING... 5 3 SWITCH (SOMETIMES KNOWN AS CASE )... 6 3.1 A BIT ABOUT BREAK... 7 4 CONDITIONAL

More information