# Calculator. Introduction. Requirements. Design. The calculator control system. F. Wagner August 2009

Size: px
Start display at page:

Download "Calculator. Introduction. Requirements. Design. The calculator control system. F. Wagner August 2009"

Transcription

1 F. Wagner August 2009 Calculator Introduction This case study is an introduction to making a specification with StateWORKS Studio that will be executed by an RTDB based application. The calculator known from Microsoft Windows systems is taken as the application. Although the power of the StateWORKS concept only shows up significantly in larger projects with many state machines, this case study, with a single state machine, raises a number of interesting issues, common to all StateWORKS projects. A discussion of issues relevant to this project may be found on the StateWORKS blog, at The case study gives also an example of using the complement value. We will learn also that StateWORKS has a RtdbClient for C# programs. Requirements The calculator has the following keys: 0..9,., +, -, *, /, ±, =, C, CE and 1-operand keys: 1/x, x 2, sqrt. In any situation the calculator has to produce a correct result defined by the well known arithmetic rules. If the calculations is impossible the calculator has to display information helping the user to resolve the erroneous situation, like: On encountering a division by 0 the display should read "Cannot divide by 0" and typing the key C should reset the calculator. On calculating the square root value of a negative operand the display should read "Wrong operand". On erroneous operand or operation keys the display should read Reset (C) to continue or Clear (CE) to continue as appropriate. Of course, any situation can be cleared using the main reset key C. Design The calculator control system Before we start to think about a calculator state machine we should make a design of the calculator control system. We may consider a calculator control as a system that reacts to keys performing all elementary actions. This approach is a dead end street leading to a very complex state machine that is difficult to handle. We will define another way that is based on the observation that a calculator is a builder of strings that are executed when complete. The rules for handling such a calculator system are fairly simple: Parse the incoming keys and assign them to the appropriate control value. Complete an Expression string from incoming keys. Perform a calculation defined by the Expression string according to arithmetic rules, when 1/12

2 encountering operator keys +, -, *, / as well as the Equals key =. We notice that we need several calculation functions as the the rule for a calculation after Equals key and addition and subtraction operators are different than for multiplication and division operators. The RTDB based control As we are going to define a calculator control realized by a StateWORKS run-time system, and in fact implemented by defining the specification we have to take into account the RTDB objects used. The objects have specific control features that are used by the specification [1]. We will use only two types of objects: DAT and OFUN. The functioning of an object DAT is described by the state transition diagram in Figure 1. After start-up a DAT object is in the state UNDEF. The first data change forces it to go to the state CHANGED. If the DAT state is used (consumed) by another object, it goes to the state DEF. Effectively, it loops between the states DEF and CHANGED: any data changes forces it to go to the state CHANGED and if this event is used by another object it returns to the state DEF. Figure 1: DAT state transition diagram The object OFUN is an interface for user-written functions. It is an input/output object, i.e. it is controlled by actions and generates control values. An action is an integer number that is passed to the called function as a parameter. The control values are integer numbers return values of the called function. As the control problem has been defined as string processing we will use objects of type DAT for storing strings. The objects of type OFUN will be used to call Output Functions. The Output Functions will access the object DAT to do the actual data processing. Therefore they are specified in an I/O Unit used by programming the Output Functions. So, we have to design a system which recognizes incoming keys, builds a syntactically correct Expression string and performs arithmetic operations if they are due. The task of the state machine is to call appropriate functions and handle erroneous situations caused by unexpected keys or calculation errors. According to StateWORKS design philosophy we are going to specify a state machine that performs the control flow. The data flow will be realized by specific Output Functions: we will use parsers to do the job of constructing the operands as well as doing the calculations. 2/12

3 RTDB objects required Before we continue we should decide what objects are required for the Calculator control. In this moment we see the following DAT objects: Key to store the entered keys Expression to store the Expression string to be processed Display to show the entered keys and the calculation result Result to store the last result (due to its double function Display cannot store the result) For specifying the state machine we need also objects of type OFUN that are the software interface to the Output Function. We need several functions shown in Table 2. Instead of providing an OFUN object for each function we define only two of them which we call: Ofu_Parse Ofu_Calculate Later we will add another OFUN object: Ofu_Expression Each Output Function receives a parameter (the value of the Output name) which is used to select the called function. Control values The specification of the state machine requires a definition of control (input) values and output values. Analyzing the possible impact on the control we distinguish a few groups of keys that define the control values in Table 1. Any key in a group has the same impact on the state machine behavior. For instance, typing the key + has the same effect as typing the key -. Similarly, typing the key sqrt has the same effect as typing the 1/x. We discuss behavior and not the calculation result. The called function knows the specific key typed and performs the calculation taking into account that key. As we use the DAT data type for storing the Key value a change of the object Key value is represented by the control value Key_CHANGED which activates the output MatchKey calling the function Parse (see the object Ofu_Parse) with the parameter 1. The function Parse returns a value identifying the key. The functions Calculate (see the object Ofu_Calculate) returns a value indicating whether the calculation has been successful or failed. The functions ExpressionCheck (see the object Ofu_Expression) returns a value indicating whether the Expression is empty. Appendix 1 shows the declarations of the Output Functions which will need to be programmed. Parsing the key The task of the state machine will be to supervise the keys typed at any time. First, the state machine decides whether the entered key make sense in a given situation. If unexpected the key may be ignored or should produce an info on the display. If the key is expected the state machine should decide what to do at that moment. The decision is very coarse; its is not the task of the state machine to decide which arithmetic operation to do. Output Functions return a value that 3/12

4 corresponds to the result and this value is used by the state machine as a control value to supervise the calculation process. Table 1: Control values Meaning Keys Object Control value Key change Key Key_CHANGED Digit 0-9,. Ofu_Parse DigitMatched AddSub +, - Ofu_Parse AddSubMatched MulDiv *, / Ofu_Parse MulDivMatched Equals = Ofu_Parse EqualsMatched Sign ± Ofu_Parse SignMatched Backspace Backspace Ofu_Parse Backspace 1Op 1/x, %, sqrt Ofu_Parse 1OpMatched Clear CE Ofu_Parse ClearMatched Reset C Ofu_Parse ResetMatched No key (empty) Ofu_Parse AckMatched Calculation ok Ofu_Calculate Ok Calculation error Ofu_Calculate Error Expression is empty Ofu_Expression ExprEmpty Expression is not empty Ofu_Expression ExprNotEmpty The key role in the state machine execution will play the object Key which change will trigger the function MatchKey via the Output Function Parse. This function will return the control value Key_CHANGED (see Table 1). Any key change will trigger an action that will also clear the key; this is necessary to allow a repetition of the same key. Clearing the key will generate another Key_CHANGED control value but this time the function Parse will return an acknowledgment signal AckMatched which actually means the key is an empty string. AckMatched plays an important role in a specification, being used to terminate transitions. Output names The Output names define the functions (see Table 2) that are to be called as Input-, Entry- or Exit- Actions. All objects used are strings; hence the functions are parsers analyzing strings and transforming them only locally to float numbers for calculations. The functions are called using Output Functions Parse and Calculate. Later we will add another Output Function called Expression. An Output Function gets a parameter (Output name) which defines the specific function 4/12

5 to be called by the Output Function. So, for instance getting the parameter 7 the Output Function Calculate will carry out a specific function AddToNumber(). Building operands Typing a Digit key should activate a function AddToNumber that creates the operand. The function creates a string from the digits and a dot character. The string must have not more than one dot, no trailing zeros and a leading zero must be added if the first entered key is a dot. Table 2: Output Functions Triggered by +,-,*,/,= keys Triggered by other keys Function defined by Output name OFUN Parameter MatchKey Ofu_Parse 1 AddToNumber Ofu_Calculate 7 CalculateLast Ofu_Calculate 6 CalculateAll Ofu_Calculate 5 CalculateT Ofu_Calculate 10 ChangeSign Ofu_Calculate 9 DeleteLastDigit Ofu_Calculate 8 Calculate1Op Ofu_Calculate 12 Reset Ofu_Calculate 15 Clear Ofu_Calculate 13 Auxiliary DisplayResetMsg Ofu_Calculate 4 DisplayClearMsg Ofu_Calculate 3 ChangeOperation Ofu_Calculate 14 ClearDisplay Ofu_Parse 2 PrepareExpressionT Ofu_Parse 3 CheckExpression Ofu_Expression 1 Calculating operations The function that performs arithmetic operations: +, -, *, / is a more complex one. To start with, we define two such functions: CalculateAll and CalculateLast that are results of the following observations: clicking on a key that triggers an arithmetic operation (+, -, *, /, =) the function called gets a few possible strings that are illustrated by examples shown in Table 3. The strings that are at any time to be processed require maximum none, one or two operations, whereas +, -, = may trigger up to two operations and *, / may trigger max one operation. In principle, the function CalculateAll will be called if the keys +,-,= are used and the CalculateLast will be triggered by keys * or /. The other functions are straightforward ones like: ClearDisplay or ChangeSign; their names 5/12

6 define quite well their simple functionality. Understanding the rules of operations that are to be carried out in the calculator we are able to start the specification of the calculator state machine that we have called Calculator. Table 3: Examples of basic calculations String Calculation Number of operations 2.3+ do nothing none * do nothing none add and continue with one = add and terminate (result 6.37) one *2* multiply and continue with 2.3+8,14* one *2+ multiply and add and continue with two *2= multiply and add and terminate (result 10.44) two State machine specification We begin with a simple calculator with functionality limited to the four arithmetic functions represented by the keys +,-,*,/. In next stages we shall expand it to a standard calculator corresponding more or less to the Windows one. But we improve on it, by adopting the normal operator precedence rules for arithmetic expressions, as in fact in the scientific mode of the Windows calculator. The projects should be opened in a StateWORKS development environment so as to see all the project details. Simple calculator The state machine CalculatorSimple is shown in Figure 2. The calculation is triggered by a change of the object Key. As this event should trigger the state machine in any state we put it in the Always section (see Figure 3). The discussion below refers to the specification details in the document Calculator.xml (note that this document applies to the full Standard calculator). The Calculator has many Actions. Assuming that each action will be an Entry Action of a state the state machine will have a lot of states. Using the Mealy model we will as a rule need fewer states. We try to optimize the design using a mixed Mealy-Moore model. As a rule, the state machine is designed in such a way that an event triggers an Input Action in the present state and forces a transition to another state. The other state is a busy state whose function is to acknowledge the realization of the calculation function (see the discussion in the section Parsing the key ). This acknowledgment is ANDed with the calculation result which determines the next done state. So, for instance if a digit key is entered (DigitMatched) in the state Init the Input Action ClearDisplay is 6/12

7 performed and the state machine goes to the state AddToNumber where the Entry Action AddToNumber is performed. The end of the calculation forces the transition to the state Number. Several keys (Backspace, +,/,-, *, C) cause the Input Action to be done and then go the state Idle_Busy waiting there for the calculation acknowledgment. The state machine returns to the state Idle either directly (if the calculation result is Ok) or via Error or ErrorClear state if the calculation is erroneous; there are various different errors possible. The state machine waits in the error states for keys: C and/or CE returning eventually via Idle_Return to the state Idle. In the error states we see a an interesting use of the complement value (see [2]) replacing the long OR condition of all keys matched that are relevant in this situation. It is especially important if the number of keys grows for a more complex calculator. The state machine has four done states Idle, Number, Error and ErrorClear where the state machines waits for keys. Other states are busy states where the states machine waits briefly for acknowledgment of the calculation. Figure 2: The Calculator Simple state transition diagram To expand the functionality of this simple calculator we would like to add the cash register function and a few 1-operand functions (1/x, %, sqrt). Extension by a cash register function The cash register function is a quite challenging problem. We use this term as it reminds one of the functionality of the key + on a cash register which is used to repeat the last addition operation. The windows calculator has some more sophisticated functionality whose sense is not quite clear. 7/12

8 At least we have not found any description of that feature. On any calculator the use of the Equals key (=) ends the current calculation. On many calculators repeated use of this key is just ignored. On a Windows calculator the repeated use of the Equals key produces some results that seem at first glance difficult to understand. Testing it long enough you discover the algorithm: it repeats the last operation with the last operand, whereas the terms last operand and last operation apply to the last operation performed on the Expression string (do not forget we stick to the normal arithmetic priority rules). A possible reason for this feature is to calculate compound interest. Entering 1.06 * = one sees the square of 1.06, that is Further use of the = key then multiples the result by 1.06 again each time, and it can show that 12 years compund interest at 6% will double a sum of money. Te cash register function is illustrated by some examples shown in Table 4. We decided to implement the algorithm used in the Windows calculator considering it as an interesting challenge, without being sure what is it for. We even suspect that it is a side effect of the calculation algorithm used and not a requirement. Table 4: Examples for the cash register function Expression Result Expression T 2+7= , = , = , *= , 8 2-7*3= -19-7*3-40, -61 5/2= 2.5 /2 1,25, Next results 1.05*= * , To keep conformance with the general idea of processing strings in a calculator we decided to work out an ExpressionT string for the cash register function that can be derived from the Extension string used for calculations. Thus, if the Extension string changes the ExtensionT is actualized to be prepared at any time for a repeated sequence of the Equals string. To realize this functionality we need an object ExpressionT, a function PrepareExpressionT and a control value Expression_CHECKED signaling the change of the Expression. In addition, we need the information about the content of the Expression: if the Expression changes the function ExpressionCheck is called and it has to be done at any time (see Figure 3). If the Expression is empty the ExpressionT is fixed and cannot be changed, otherwise it has to be changed according to the content of the Expression string. For processing of the ExpressionT we need an additional function CalculateT. Figure 3: The Calculator state table: the section Always 8/12

9 To control the call to of the CalculateT t state machine gets an additional state CalculateT where the state machine goes always to the state Idle when the Equals key is matched. For details see the details of the specification of the state machine. The new state transition diagram is shown in Figure 4 and the full details are found in the document Calculator.xml. Figure 4: The Calculator Simple with added cash register function: state transition diagram Standard calculator The extension to 1-operand functions such as sqrt is relatively easy. These functions are simple calculations so we call corresponding functions as input actions in the states Idle and Number. Figure 5 shows the state transition diagram of the complete Standard calculator. The 1-operand functions are treated as other functions: they trigger an Input Action in the present state and go the busy state where they wait for an calculation result. The only change in the state transition diagram is related to the error handling in the state Number. Depending on the calculation result and the user reaction (the use of a key C or CE) an 1-operand function may require a return to the state Number or a transition to the state Init. The additional states: Num_Busy, Num_ErrorClear and Num_Return are required to solve the additional requirements. The details of the state transition diagram are in the document Calculator.xml and the full specification for an RTDB based execution system which performs the Calculator in the document Standard.xml. 9/12

10 Figure 5: The Calculator Standard state transition diagram Testing To test the design we have written a Calculator User Interface CalculatorUI (see Figure 6). Figure 6: User interface for the Calculator 10/12

11 It is a program written in C#. The user interface starts the Calculator and connects via tcp/ip interface (RtdbClient DLL) to it. The Calculator is an RTDB based embedded application. It allows testing of Calculator functionality. This study has been devoted to the control problem of a Calculator. Therefore when writing the calculation function we did not care about the numerical problems, just using the standard C++ arithmetic function for double float numbers. Conclusions The design, specification and implementation of a calculator illustrates well the concept of the partition of control and data flow based on the virtual environment idea. The basic idea of the software solution for a calculator is to parse the string created by keys typed and execute it if appropriate. It sounds simple. The difficulty is the control of unexpected sequences of keys. We may say that the parser should react appropriately detecting the unexpected keys. The problem is that the definition of an unexpected key is context dependent. To recognize the context by conventional programming we may use flags and this is the source of problems: the control of flags leads to obscure programs that are difficult to develop and maintain. Experience shows that we may become crazy working with such software. Flags in a program mean that the software has a sequential character and the flags may be replaced by a state machine which is in a rule far easier to understand than the flags. The state machine required by any software is a result of analysis and design. Before we start to specify a state machine we must work out a clear picture of the task that the state machine is to take over. The aim of introduction of the state machine in software is not to eliminate all if then else statements. No, the state machine is required to take over the sequential (state dependent) part of the software control. For instance, the state machine should not be involved into checking whether the divisor equals 0. If you start to define a state machine on that level you will get a monster that may be as difficult to understand as chaotic software with flags. In the design phase you have to identify the essential control problem that is to be realized by the state machine. The design is the most difficult and responsible part of the project. A design determines the quality of the software, in that case the quality of the control flow. The use of state machines in the software does not automatically guarantees a better result. The correct use of state machines is the aim. Failures in the existing calculators demonstrate that the programming approach used has been not good. Even in such a not very complex software a programmer was not able to get a reliable result, i.e. calculators working always in an intuitively reasonable fashion. If correctly applied, the state machine concept allows us to produce software that works exactly as required. Any changes or expansions can be done fairly easily without any danger of crashing the existing part. This is a feature of StateWORKS valid when applied to much larger projects. We have discussed the essential phases of a project: - Defining the application - Designing the control system - Specifying the state machine StateWORKS is a system generating a true executable specification. It is achieved by transforming the real signals into the virtual environment. The actual specification of the system behavior modeled by state machines is done using control values and action defined for the RTDB objects. The state machine as designed could be a good starting point to expand its functionality to the Windows Scientific calculator. In principle, it requires addition of functions for the other 1-operand keys. This means that the state machine diagram should change only slightly if ever. 11/12

12 References 1. Wagner, F. et al., Modeling Software with Finite State Machines A Practical Approach, Auerbach Publications, The technical note Complement control values in the VFSM concept. Appendix 1. Output Function declarations int Parse( CItem* powner, int nvo ) // The function recognizes the content (character) of the object Key and // returns an enumeration value characterizing the character. // It is used also to perform some auxilary functions like: // ClearDisplay and PrepareExpressionT. // Input: powner -> a pointer to the I/O UNit containing the RTDB objects // nvo -> a parameter determined by the state machine Output name: // see enumeration ParseFunction // Output: Return value of the type ParseResult int Calculate( CItem* powner, int nvo ) // The function selects a parser/calculation function to be performed. // The selected functions require the Key value; if the Key value is // an empty string the function returns immediately with // CalculateResult_Ignored. // Input: powner -> a pointer to the I/O UNit containing the RTDB objects // nvo -> a parameter determined by the state machine Output name: // see enumeration CalculateFunction // Output: Return value of the type CalculationResult int ExpressionCheck( CItem* powner, int nvo ) // The function recognizes the content of the object Expression and // returns an enumeration value indicating whether its is empty or not. // Input: powner -> a pointer to the I/O UNit containing the RTDB objects // nvo -> a parameter determined by the state machine Output name: // see enumeration ExpressionResult // Output: Return value of the type ExpressionResult 12/12

### 1 Description of The Simpletron

Simulating The Simpletron Computer 50 points 1 Description of The Simpletron In this assignment you will write a program to simulate a fictional computer that we will call the Simpletron. As its name implies

### Informatica e Sistemi in Tempo Reale

Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)

### Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to

### Sources: On the Web: Slides will be available on:

C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,

### Exercise 4 Learning Python language fundamentals

Exercise 4 Learning Python language fundamentals Work with numbers Python can be used as a powerful calculator. Practicing math calculations in Python will help you not only perform these tasks, but also

### We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.

LING115 Lecture Note Session #4 Python (1) 1. Introduction As we have seen in previous sessions, we can use Linux shell commands to do simple text processing. We now know, for example, how to count words.

### Module 10. Coding and Testing. Version 2 CSE IIT, Kharagpur

Module 10 Coding and Testing Lesson 23 Code Review Specific Instructional Objectives At the end of this lesson the student would be able to: Identify the necessity of coding standards. Differentiate between

### Introduction to Python

Caltech/LEAD Summer 2012 Computer Science Lecture 2: July 10, 2012 Introduction to Python The Python shell Outline Python as a calculator Arithmetic expressions Operator precedence Variables and assignment

### MICROPROCESSOR. Exclusive for IACE Students www.iace.co.in iacehyd.blogspot.in Ph: 9700077455/422 Page 1

MICROPROCESSOR A microprocessor incorporates the functions of a computer s central processing unit (CPU) on a single Integrated (IC), or at most a few integrated circuit. It is a multipurpose, programmable

### Chapter One Introduction to Programming

Chapter One Introduction to Programming 1-1 Algorithm and Flowchart Algorithm is a step-by-step procedure for calculation. More precisely, algorithm is an effective method expressed as a finite list of

1 2 Introduction to Java Applications 2.2 First Program in Java: Printing a Line of Text 2 Application Executes when you use the java command to launch the Java Virtual Machine (JVM) Sample program Displays

### Python Programming: An Introduction To Computer Science

Python Programming: An Introduction To Computer Science Chapter 8 Booleans and Control Structures Python Programming, 2/e 1 Objectives æ To understand the concept of Boolean expressions and the bool data

### Computer Science 281 Binary and Hexadecimal Review

Computer Science 281 Binary and Hexadecimal Review 1 The Binary Number System Computers store everything, both instructions and data, by using many, many transistors, each of which can be in one of two

### Hands-on Exercise 1: VBA Coding Basics

Hands-on Exercise 1: VBA Coding Basics This exercise introduces the basics of coding in Access VBA. The concepts you will practise in this exercise are essential for successfully completing subsequent

### 7.1 Our Current Model

Chapter 7 The Stack In this chapter we examine what is arguably the most important abstract data type in computer science, the stack. We will see that the stack ADT and its implementation are very simple.

### VIRTUAL LABORATORY: MULTI-STYLE CODE EDITOR

VIRTUAL LABORATORY: MULTI-STYLE CODE EDITOR Andrey V.Lyamin, State University of IT, Mechanics and Optics St. Petersburg, Russia Oleg E.Vashenkov, State University of IT, Mechanics and Optics, St.Petersburg,

### (Refer Slide Time: 00:01:16 min)

Digital Computer Organization Prof. P. K. Biswas Department of Electronic & Electrical Communication Engineering Indian Institute of Technology, Kharagpur Lecture No. # 04 CPU Design: Tirning & Control

### Visual Logic Instructions and Assignments

Visual Logic Instructions and Assignments Visual Logic can be installed from the CD that accompanies our textbook. It is a nifty tool for creating program flowcharts, but that is only half of the story.

### If A is divided by B the result is 2/3. If B is divided by C the result is 4/7. What is the result if A is divided by C?

Problem 3 If A is divided by B the result is 2/3. If B is divided by C the result is 4/7. What is the result if A is divided by C? Suggested Questions to ask students about Problem 3 The key to this question

### OAMulator. Online One Address Machine emulator and OAMPL compiler. http://myspiders.biz.uiowa.edu/~fil/oam/

OAMulator Online One Address Machine emulator and OAMPL compiler http://myspiders.biz.uiowa.edu/~fil/oam/ OAMulator educational goals OAM emulator concepts Von Neumann architecture Registers, ALU, controller

### Moving from CS 61A Scheme to CS 61B Java

Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you

### Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine

7 Objectives After completing this lab you will: know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine Introduction Branches and jumps provide ways to change

### Part 1 Foundations of object orientation

OFWJ_C01.QXD 2/3/06 2:14 pm Page 1 Part 1 Foundations of object orientation OFWJ_C01.QXD 2/3/06 2:14 pm Page 2 1 OFWJ_C01.QXD 2/3/06 2:14 pm Page 3 CHAPTER 1 Objects and classes Main concepts discussed

### COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing

COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing The scanner (or lexical analyzer) of a compiler processes the source program, recognizing

### EMC Publishing. Ontario Curriculum Computer and Information Science Grade 11

EMC Publishing Ontario Curriculum Computer and Information Science Grade 11 Correlations for: An Introduction to Programming Using Microsoft Visual Basic 2005 Theory and Foundation Overall Expectations

### Simple C++ Programs. Engineering Problem Solving with C++, Etter/Ingber. Dev-C++ Dev-C++ Windows Friendly Exit. The C++ Programming Language

Simple C++ Programs Engineering Problem Solving with C++, Etter/Ingber Chapter 2 Simple C++ Programs Program Structure Constants and Variables C++ Operators Standard Input and Output Basic Functions from

### How to build agent based models. Field service example

Simulation Modeling with AnyLogic: Agent Based, Discrete Event and System Dynamics Methods 1 How to build agent based models. Field service example Agent based modeling is the easiest modeling method.

### Scoping (Readings 7.1,7.4,7.6) Parameter passing methods (7.5) Building symbol tables (7.6)

Semantic Analysis Scoping (Readings 7.1,7.4,7.6) Static Dynamic Parameter passing methods (7.5) Building symbol tables (7.6) How to use them to find multiply-declared and undeclared variables Type checking

### C Compiler Targeting the Java Virtual Machine

C Compiler Targeting the Java Virtual Machine Jack Pien Senior Honors Thesis (Advisor: Javed A. Aslam) Dartmouth College Computer Science Technical Report PCS-TR98-334 May 30, 1998 Abstract One of the

### The Clean programming language. Group 25, Jingui Li, Daren Tuzi

The Clean programming language Group 25, Jingui Li, Daren Tuzi The Clean programming language Overview The Clean programming language first appeared in 1987 and is still being further developed. It was

### Streaming Lossless Data Compression Algorithm (SLDC)

Standard ECMA-321 June 2001 Standardizing Information and Communication Systems Streaming Lossless Data Compression Algorithm (SLDC) Phone: +41 22 849.60.00 - Fax: +41 22 849.60.01 - URL: http://www.ecma.ch

### C++ Programming: From Problem Analysis to Program Design, Fifth Edition. Chapter 3: Input/Output

C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 3: Input/Output Objectives In this chapter, you will: Learn what a stream is and examine input and output streams Explore

### Compiler Construction

Compiler Construction Regular expressions Scanning Görel Hedin Reviderad 2013 01 23.a 2013 Compiler Construction 2013 F02-1 Compiler overview source code lexical analysis tokens intermediate code generation

### Positional Numbering System

APPENDIX B Positional Numbering System A positional numbering system uses a set of symbols. The value that each symbol represents, however, depends on its face value and its place value, the value associated

### Chapter 2: Elements of Java

Chapter 2: Elements of Java Basic components of a Java program Primitive data types Arithmetic expressions Type casting. The String type (introduction) Basic I/O statements Importing packages. 1 Introduction

### 13 File Output and Input

SCIENTIFIC PROGRAMMING -1 13 File Output and Input 13.1 Introduction To make programs really useful we have to be able to input and output data in large machinereadable amounts, in particular we have to

### Lecture 8: Binary Multiplication & Division

Lecture 8: Binary Multiplication & Division Today s topics: Addition/Subtraction Multiplication Division Reminder: get started early on assignment 3 1 2 s Complement Signed Numbers two = 0 ten 0001 two

### Object Oriented Software Design

Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 28, 2010 G. Lipari (Scuola Superiore Sant Anna) Introduction

### QUIZ-II QUIZ-II. Chapter 5: Control Structures II (Repetition) Objectives. Objectives (cont d.) 20/11/2015. EEE 117 Computer Programming Fall-2015 1

QUIZ-II Write a program that mimics a calculator. The program should take as input two integers and the operation to be performed. It should then output the numbers, the operator, and the result. (For

### The programming language C. sws1 1

The programming language C sws1 1 The programming language C invented by Dennis Ritchie in early 1970s who used it to write the first Hello World program C was used to write UNIX Standardised as K&C (Kernighan

### Computer Programming I & II*

Computer Programming I & II* Career Cluster Information Technology Course Code 10152 Prerequisite(s) Computer Applications, Introduction to Information Technology Careers (recommended), Computer Hardware

### JavaScript: Control Statements I

1 7 JavaScript: Control Statements I 7.1 Introduction 2 The techniques you will learn here are applicable to most high-level languages, including JavaScript 1 7.2 Algorithms 3 Any computable problem can

Advanced Aircraft Analysis 3.6 Network Floating License Installation 1 Introduction DARcorporation uses the WIBU-Systems WIBU-KEY Copy Protection concept for the AAA network licensing. The WIBU-KEY concept

### PGR Computing Programming Skills

PGR Computing Programming Skills Dr. I. Hawke 2008 1 Introduction The purpose of computing is to do something faster, more efficiently and more reliably than you could as a human do it. One obvious point

### Static vs. Dynamic. Lecture 10: Static Semantics Overview 1. Typical Semantic Errors: Java, C++ Typical Tasks of the Semantic Analyzer

Lecture 10: Static Semantics Overview 1 Lexical analysis Produces tokens Detects & eliminates illegal tokens Parsing Produces trees Detects & eliminates ill-formed parse trees Static semantic analysis

### A Static Analyzer for Large Safety-Critical Software. Considered Programs and Semantics. Automatic Program Verification by Abstract Interpretation

PLDI 03 A Static Analyzer for Large Safety-Critical Software B. Blanchet, P. Cousot, R. Cousot, J. Feret L. Mauborgne, A. Miné, D. Monniaux,. Rival CNRS École normale supérieure École polytechnique Paris

### CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

Oct 4, 2013, p 1 Name: CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 1. (max 18) 4. (max 16) 2. (max 12) 5. (max 12) 3. (max 24) 6. (max 18) Total: (max 100)

### Glossary of Object Oriented Terms

Appendix E Glossary of Object Oriented Terms abstract class: A class primarily intended to define an instance, but can not be instantiated without additional methods. abstract data type: An abstraction

### Object Oriented Software Design

Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa September 14, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction

### Understanding class definitions

OFWJ_C02.QXD 2/3/06 2:28 pm Page 17 CHAPTER 2 Understanding class definitions Main concepts discussed in this chapter: fields methods (accessor, mutator) constructors assignment and conditional statement

### WA Manager Alarming System Management Software Windows 98, NT, XP, 2000 User Guide

WA Manager Alarming System Management Software Windows 98, NT, XP, 2000 User Guide Version 2.1, 4/2010 Disclaimer While every effort has been made to ensure that the information in this guide is accurate

### University of Hull Department of Computer Science. Wrestling with Python Week 01 Playing with Python

Introduction Welcome to our Python sessions. University of Hull Department of Computer Science Wrestling with Python Week 01 Playing with Python Vsn. 1.0 Rob Miles 2013 Please follow the instructions carefully.

### Introduction to Python

WEEK ONE Introduction to Python Python is such a simple language to learn that we can throw away the manual and start with an example. Traditionally, the first program to write in any programming language

### Chapter 5 Names, Bindings, Type Checking, and Scopes

Chapter 5 Names, Bindings, Type Checking, and Scopes Chapter 5 Topics Introduction Names Variables The Concept of Binding Type Checking Strong Typing Scope Scope and Lifetime Referencing Environments Named

### KS3 Computing Group 1 Programme of Study 2015 2016 2 hours per week

1 07/09/15 2 14/09/15 3 21/09/15 4 28/09/15 Communication and Networks esafety Obtains content from the World Wide Web using a web browser. Understands the importance of communicating safely and respectfully

### Divide: Paper & Pencil. Computer Architecture ALU Design : Division and Floating Point. Divide algorithm. DIVIDE HARDWARE Version 1

Divide: Paper & Pencil Computer Architecture ALU Design : Division and Floating Point 1001 Quotient Divisor 1000 1001010 Dividend 1000 10 101 1010 1000 10 (or Modulo result) See how big a number can be

### 2) Write in detail the issues in the design of code generator.

COMPUTER SCIENCE AND ENGINEERING VI SEM CSE Principles of Compiler Design Unit-IV Question and answers UNIT IV CODE GENERATION 9 Issues in the design of code generator The target machine Runtime Storage

### 9 Control Statements. 9.1 Introduction. 9.2 Objectives. 9.3 Statements

9 Control Statements 9.1 Introduction The normal flow of execution in a high level language is sequential, i.e., each statement is executed in the order of its appearance in the program. However, depending

### Sequential Logic Design Principles.Latches and Flip-Flops

Sequential Logic Design Principles.Latches and Flip-Flops Doru Todinca Department of Computers Politehnica University of Timisoara Outline Introduction Bistable Elements Latches and Flip-Flops S-R Latch

### Traditional IBM Mainframe Operating Principles

C H A P T E R 1 7 Traditional IBM Mainframe Operating Principles WHEN YOU FINISH READING THIS CHAPTER YOU SHOULD BE ABLE TO: Distinguish between an absolute address and a relative address. Briefly explain

### PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?

1. Distinguish & and && operators. PART-A Questions 2. How does an enumerated statement differ from a typedef statement? 3. What are the various members of a class? 4. Who can access the protected members

### PROGRAMMABLE LOGIC CONTROL

PROGRAMMABLE LOGIC CONTROL James Vernon: control systems principles.co.uk ABSTRACT: This is one of a series of white papers on systems modelling, analysis and control, prepared by Control Systems Principles.co.uk

### Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

Formal Languages and Automata Theory - Regular Expressions and Finite Automata - Samarjit Chakraborty Computer Engineering and Networks Laboratory Swiss Federal Institute of Technology (ETH) Zürich March

### ALGORITHMS AND FLOWCHARTS

ALGORITHMS AND FLOWCHARTS A typical programming task can be divided into two phases: Problem solving phase produce an ordered sequence of steps that describe solution of problem this sequence of steps

### Welcome to Introduction to programming in Python

Welcome to Introduction to programming in Python Suffolk One, Ipswich, 4:30 to 6:00 Tuesday Jan 14, Jan 21, Jan 28, Feb 11 Welcome Fire exits Toilets Refreshments 1 Learning objectives of the course An

### 2014 HSC Software Design and Development Marking Guidelines

014 HSC Software Design and Development Marking Guidelines Section I Multiple-choice Answer Key Question Answer 1 B A A 4 D 5 A 6 D 7 A 8 B 9 C 10 D 11 B 1 B 1 A 14 A 15 B 16 D 17 C 18 C 19 D 0 D 1 Section

Chapter 7: Software Development Stages Test your knowledge - answers 1. What is meant by constraints and limitations on program design? Constraints and limitations are based on such items as operational,

### Random Fibonacci-type Sequences in Online Gambling

Random Fibonacci-type Sequences in Online Gambling Adam Biello, CJ Cacciatore, Logan Thomas Department of Mathematics CSUMS Advisor: Alfa Heryudono Department of Mathematics University of Massachusetts

### Comparing RTOS to Infinite Loop Designs

Comparing RTOS to Infinite Loop Designs If you compare the way software is developed for a small to medium sized embedded project using a Real Time Operating System (RTOS) versus a traditional infinite

### GETTING STARTED WITH LABVIEW POINT-BY-POINT VIS

USER GUIDE GETTING STARTED WITH LABVIEW POINT-BY-POINT VIS Contents Using the LabVIEW Point-By-Point VI Libraries... 2 Initializing Point-By-Point VIs... 3 Frequently Asked Questions... 5 What Are the

### [Refer Slide Time: 05:10]

Principles of Programming Languages Prof: S. Arun Kumar Department of Computer Science and Engineering Indian Institute of Technology Delhi Lecture no 7 Lecture Title: Syntactic Classes Welcome to lecture

### Data Structure with C

Subject: Data Structure with C Topic : Tree Tree A tree is a set of nodes that either:is empty or has a designated node, called the root, from which hierarchically descend zero or more subtrees, which

### VISUAL ALGEBRA FOR COLLEGE STUDENTS. Laurie J. Burton Western Oregon University

VISUAL ALGEBRA FOR COLLEGE STUDENTS Laurie J. Burton Western Oregon University VISUAL ALGEBRA FOR COLLEGE STUDENTS TABLE OF CONTENTS Welcome and Introduction 1 Chapter 1: INTEGERS AND INTEGER OPERATIONS

### White Paper. Blindfolded SQL Injection

White Paper In the past few years, SQL Injection attacks have been on the rise. The increase in the number of Database based applications, combined with various publications that explain the problem and

### Accounts Receivable System Administration Manual

Accounts Receivable System Administration Manual Confidential Information This document contains proprietary and valuable, confidential trade secret information of APPX Software, Inc., Richmond, Virginia

### Two's Complement Adder/Subtractor Lab L03

Two's Complement Adder/Subtractor Lab L03 Introduction Computers are usually designed to perform indirect subtraction instead of direct subtraction. Adding -B to A is equivalent to subtracting B from A,

### BA-35 Solar Quick Reference Guide

BA-35 Solar Quick Reference Guide Table of Contents General Information... 2 The Display... 4 Arithmetic Operations... 6 Correcting Errors... 7 Display Formats... 8 Memory Operations... 9 Math Operations...

### Kids College Computer Game Programming Exploring Small Basic and Procedural Programming

Kids College Computer Game Programming Exploring Small Basic and Procedural Programming According to Microsoft, Small Basic is a programming language developed by Microsoft, focused at making programming

### Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

Translation Translating to Java Introduction to Computer Programming The job of a programmer is to translate a problem description into a computer language. You need to be able to convert a problem description

### Math Review. for the Quantitative Reasoning Measure of the GRE revised General Test

Math Review for the Quantitative Reasoning Measure of the GRE revised General Test www.ets.org Overview This Math Review will familiarize you with the mathematical skills and concepts that are important

### Order of Operations More Essential Practice

Order of Operations More Essential Practice We will be simplifying expressions using the order of operations in this section. Automatic Skill: Order of operations needs to become an automatic skill. Failure

### Lecture 9. Semantic Analysis Scoping and Symbol Table

Lecture 9. Semantic Analysis Scoping and Symbol Table Wei Le 2015.10 Outline Semantic analysis Scoping The Role of Symbol Table Implementing a Symbol Table Semantic Analysis Parser builds abstract syntax

### How To Port A Program To Dynamic C (C) (C-Based) (Program) (For A Non Portable Program) (Un Portable) (Permanent) (Non Portable) C-Based (Programs) (Powerpoint)

TN203 Porting a Program to Dynamic C Introduction Dynamic C has a number of improvements and differences compared to many other C compiler systems. This application note gives instructions and suggestions

### ALLIED PAPER : DISCRETE MATHEMATICS (for B.Sc. Computer Technology & B.Sc. Multimedia and Web Technology)

ALLIED PAPER : DISCRETE MATHEMATICS (for B.Sc. Computer Technology & B.Sc. Multimedia and Web Technology) Subject Description: This subject deals with discrete structures like set theory, mathematical

### plc numbers - 13.1 Encoded values; BCD and ASCII Error detection; parity, gray code and checksums

plc numbers - 3. Topics: Number bases; binary, octal, decimal, hexadecimal Binary calculations; s compliments, addition, subtraction and Boolean operations Encoded values; BCD and ASCII Error detection;

### CRM Setup Factory Installer V 3.0 Developers Guide

CRM Setup Factory Installer V 3.0 Developers Guide Who Should Read This Guide This guide is for ACCPAC CRM solution providers and developers. We assume that you have experience using: Microsoft Visual

### ASSEMBLY PROGRAMMING ON A VIRTUAL COMPUTER

ASSEMBLY PROGRAMMING ON A VIRTUAL COMPUTER Pierre A. von Kaenel Mathematics and Computer Science Department Skidmore College Saratoga Springs, NY 12866 (518) 580-5292 pvonk@skidmore.edu ABSTRACT This paper

### Purpose EL-773A HP-10B BA-II PLUS Clear memory 0 n registers

D-How to Use a Financial Calculator* Most personal finance decisions involve calculations of the time value of money. Three methods are used to compute this value: time value of money tables (such as those

### Notes on Assembly Language

Notes on Assembly Language Brief introduction to assembly programming The main components of a computer that take part in the execution of a program written in assembly code are the following: A set of

### Unit Testing & JUnit

Unit Testing & JUnit Lecture Outline Communicating your Classes Introduction to JUnit4 Selecting test cases UML Class Diagrams Rectangle height : int width : int resize(double,double) getarea(): int getperimeter():int

### SOME EXCEL FORMULAS AND FUNCTIONS

SOME EXCEL FORMULAS AND FUNCTIONS About calculation operators Operators specify the type of calculation that you want to perform on the elements of a formula. Microsoft Excel includes four different types

### Stacks. Linear data structures

Stacks Linear data structures Collection of components that can be arranged as a straight line Data structure grows or shrinks as we add or remove objects ADTs provide an abstract layer for various operations

### Formulas & Functions in Microsoft Excel

Formulas & Functions in Microsoft Excel Theresa A Scott, MS Biostatistician II Department of Biostatistics Vanderbilt University theresa.scott@vanderbilt.edu Table of Contents 1 Introduction 1 1.1 Using

### Comp 255Q - 1M: Computer Organization Lab #3 - Machine Language Programs for the PDP-8

Comp 255Q - 1M: Computer Organization Lab #3 - Machine Language Programs for the PDP-8 January 22, 2013 Name: Grade /10 Introduction: In this lab you will write, test, and execute a number of simple PDP-8

### First Bytes Programming Lab 2

First Bytes Programming Lab 2 This lab is available online at www.cs.utexas.edu/users/scottm/firstbytes. Introduction: In this lab you will investigate the properties of colors and how they are displayed