JAVA PROGRAMMING LAB. ABSTRACT EXTRA LAB, In this Lab you will learn working with recursion, JRX, Java documentations

Size: px
Start display at page:

Download "JAVA PROGRAMMING LAB. ABSTRACT EXTRA LAB, In this Lab you will learn working with recursion, JRX, Java documentations"

Transcription

1 Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Computer Programming Lab (ECOM 2114) ABSTRACT EXTRA LAB, In this Lab you will learn working with recursion, JRX, Java documentations JAVA PROGRAMMING LAB Eng. Mustafa J. Dalloul Computer Programming Lab 4 December 2016

2 Recursion is a technique that leads to elegant solutions to problems that are difficult to program using simple loops. Suppose you want to find all the files under a directory that contain a particular word. How do you solve this problem? There are several ways to do so. An intuitive and effective solution is to use recursion by searching the files in the subdirectories recursively. To use recursion is to program using recursive methods that is, to use methods that invoke themselves. Recursion is a useful programming technique. In some cases, it enables you to develop a natural, straightforward, simple solution to an otherwise difficult problem. Example 1: Computing the factorial Write a java method that s find the factorial for any number according to its equation: Solution: n! = n (n 1) (n 2) 1 The factorial of a number n can be recursively defined as follows: 0! = 1; n! = n (n - 1)!; n > 0 public static int fact(int n){ if(n == 0){ return 1; else{ return n*fact(n-1); 1

3 Haw its work? See the next figure: Example 2: Computing Fibonacci Numbers The Fibonacci series begins with 0 and 1, and each subsequent number is the sum of the preceding two. The series can be recursively defined as: fib(0) = 0; fib(1) = 1; fib(index) = fib(index - 2) + fib(index - 1); index >= 2 Sol: public static int fib(int index) { if (index == 0) { return 0; else if (index == 1) { return 1; else { return fib(index - 1) + fib(index - 2); 2

4 How its work? See the next figure: If you think recursively, you can solve many problems using recursion. All recursive methods have the following characteristics: The method is implemented using an if-else or a switch statement that leads to different cases. One or more base cases (the simplest case) are used to stop recursion. Every recursive call reduces the original problem, bringing it increasingly closer to a base case until it becomes that case Often you need to write the code to validate user input such as to check whether the input is a number, a string with all lowercase letters, or a social security number. How do you write this type of code? A simple and effective way to accomplish this task is to use the regular expression. A regular expression (abbreviated regex) is a string that describes a pattern for matching a set of strings. Matching Strings Let us begin with the matches method in the String class. At first glance, the matches method is very similar to the equals method. For example, the following two statements both evaluate to true. 3

5 "Java".matches("Java"); "Java".equals("Java"); However, the matches method is more powerful. It can match not only a fixed string, but also a set of strings that follow a pattern. 4

6 Example 1 The pattern for social security numbers is xxx-xx-xxxx, where x is a digit. A regular expression for social security numbers can be described as [\\d]{3-[\\d]{2-[\\d]{4 " ".matches("[\\d]{3-[\\d]{2-[\\d]{4") returns true. " ".matches("[\\d]{3-[\\d]{2-[\\d]{4") returns false. Example 2 An even number ends with digits 0, 2, 4, 6, or 8. The pattern for even numbers can be described as [\\d]*[02468] "123".matches("[\\d]*[02468]") returns false. "122".matches("[\\d]*[02468]") returns true. Example 3 The pattern for telephone numbers is (xxx) xxx-xxxx, where x is a digit and the first digit cannot be zero. A regular expression for telephone numbers can be described as \\([1-9][\\d]{2\\) [\\d]{3-[\\d]{4 Note that to use ( is a special character, to use it you must ad \\ before that "(912) ".matches("\\([1-9][\\d]{2\\) [\\d]{3-[\\d]{4") returns true. " ".matches("\\([1-9][\\d]{2\\) [\\d]{3-[\\d]{4") returns false. Example 4 Suppose the last name consists of at most 25 letters and the first letter is in uppercase. The pattern for a last name can be described as [A-Z][a-zA-Z]{1,24 "Smith".matches("[A-Z][a-zA-Z]{1,24") returns true. "Jones123".matches("[A-Z][a-zA-Z]{1,24") returns false. The matches method in the String class returns true if the string matches the regular expression. The String class also contains the replaceall, replacefirst, and split methods for replacing and splitting strings. 5

7 The replaceall method replaces all matching substring and the replacefirst method replaces the first matching substring. For example, the following code System.out.println("Java Java Java".replaceAll("v\\w", "wi")); displays Jawi Jawi Jawi The split(regex) method splits a string into substrings delimited by the matches. For example, the following statement String[] tokens = "Java1HTML2Perl".split("\\d"); splits string "Java1HTML2Perl" into Java, HTML, and Perl and saved in tokens[0], tokens[1], and tokens[2]. Structure of a Javadoc comment A Javadoc comment is set off from code by standard multi-line comment tags /* and */. The opening tag (called begin-comment delimiter), has an extra asterisk, as in /**. 1. The first paragraph is a description of the method documented. 2. Following the description are a varying number of descriptive tags, signifying: 1. The parameters of the method ) 2. What the method returns ) 3. Any exceptions the method may throw ) 4. Other less-common tags such (a "see also" tag) The basic structure of writing document comments is to embed them inside /**... */. The Javadoc is written next to the items without any separating newline. Note that any import statements must precede the class declaration. The class declaration usually contains: // import statements /** Firstname Lastname example.com> 1.8 (current version number of program) 1.2 (the version of the package this class was first added to) */ public class Test { // class body 6

8 For methods there is (1) a short, concise, one line description to explain what the item does. This is followed by (2) a longer description that may span multiple paragraphs. The details can be explained in full here. This section, marked in brackets [], is optional. Lastly, there is (3) a tag section to list the accepted input arguments and return values of the method. Note that all of the Javadoc is treated as HTML so the multiple paragraph sections are separated by a " <p> " paragraph break tag. /** * Short one line description. (1) * <p> * Longer description. If there were any, it would be (2) * here. * <p> * And even more explanations to follow in consecutive * paragraphs separated by HTML paragraph breaks. * variable Description text text text. (3) Description text text text. */ public int methodname (...) { // method body with a return statement Variables are documented similarly to methods with the exception that part (3) is omitted. Here the variable contains only the short description: /** * Description of the variable here. */ private int debug = 0; Some of the available Javadoc tags are listed in the table below Tag & Parameter Usage Applies John Smith Describes an author. Class, Interface, version Provides software version entry. Max one per Class or Interface. Class, Interface, since-text Describes when this functionality has first existed. Class, Interface, Enum, 7

9 @see reference Provides a link to other element of documentation. Class, Interface, name description Describes a method parameter. description Describes the return value. classname classname description Describes an exception that may be thrown from this method. description Describes an outdated method. Class, Interface, Enum, {@inheritdoc Copies the description from the overridden method. Overriding Method {@link reference Link to other symbol. Class, Interface, Enum, {@value #STATIC_FIELD Return the value of a static field. Static Field {@code literal Formats literal text in the code font. It is equivalent to <code>{@literal</code>. Class, Interface, Enum, {@literal literal Denotes literal text. The enclosed text is interpreted as not containing HTML markup or nested javadoc tags. Class, Interface, Enum, 8

34. Recursion. Java. Summer 2008 Instructor: Dr. Masoud Yaghini

34. Recursion. Java. Summer 2008 Instructor: Dr. Masoud Yaghini 34. Recursion Java Summer 2008 Instructor: Dr. Masoud Yaghini Outline Introduction Example: Factorials Example: Fibonacci Numbers Recursion vs. Iteration References Introduction Introduction Recursion

More information

1/16/2013. Program Structure. Language Basics. Selection/Iteration Statements. Useful Java Classes. Text/File Input and Output.

1/16/2013. Program Structure. Language Basics. Selection/Iteration Statements. Useful Java Classes. Text/File Input and Output. Program Structure Language Basics Selection/Iteration Statements Useful Java Classes Text/File Input and Output Java Exceptions Program Structure 1 Packages Provide a mechanism for grouping related classes

More information

Pace University. Fundamental Concepts of CS121 1

Pace University. Fundamental Concepts of CS121 1 Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction

More information

JAVA PROGRAMMING LAB. ABSTRACT In this Lab you will learn to write programs for executing statements repeatedly using a while, do while and for loop

JAVA PROGRAMMING LAB. ABSTRACT In this Lab you will learn to write programs for executing statements repeatedly using a while, do while and for loop Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Computer Programming Lab (ECOM 2114) ABSTRACT In this Lab you will learn to write programs for executing statements repeatedly

More information

Computer Programming: C++

Computer Programming: C++ The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2003 Muath i.alnabris Computer Programming: C++ Experiment #3 Loops Part I Contents Introduction For-Loop

More information

OVERVIEW. Recursion is an algorithmic technique where a function calls itself directly or indirectly. Why learn recursion?

OVERVIEW. Recursion is an algorithmic technique where a function calls itself directly or indirectly. Why learn recursion? CH. 5 RECURSION ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN JAVA, GOODRICH, TAMASSIA AND GOLDWASSER (WILEY 2016) OVERVIEW Recursion is an algorithmic

More information

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments. Java How to Program, 9/e Education, Inc. All Rights Reserved. } Java application programming } Use tools from the JDK to compile and run programs. } Videos at www.deitel.com/books/jhtp9/ Help you get started

More information

Marcin Luckner Warsaw University of Technology Faculty of Mathematics and Information Science

Marcin Luckner Warsaw University of Technology Faculty of Mathematics and Information Science Marcin Luckner Warsaw University of Technology Faculty of Mathematics and Information Science mluckner@mini.pw.edu.pl http://www.mini.pw.edu.pl/~lucknerm } Annotations do not directly affect program semantics.

More information

Faculty of Engineering Computer Engineering Department Islamic University of Gaza C++ Programming Language Lab # 6 Functions

Faculty of Engineering Computer Engineering Department Islamic University of Gaza C++ Programming Language Lab # 6 Functions Faculty of Engineering Computer Engineering Department Islamic University of Gaza 2013 C++ Programming Language Lab # 6 Functions C++ Programming Language Lab # 6 Functions Objective: To be familiar with

More information

Reading Input from Text File

Reading Input from Text File Islamic University of Gaza Faculty of Engineering Computer Engineering Department Computer Programming Lab (ECOM 2114) Lab 5 Reading Input from Text File Eng. Mohammed Alokshiya November 2, 2014 The simplest

More information

QueueBlock, ReversalADT, LinkedList,CustomerAccount, not MaintainCustomerData

QueueBlock, ReversalADT, LinkedList,CustomerAccount, not MaintainCustomerData Naming Conventions Rules Classes Use nouns Use whole words-avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML) Begin with upper case

More information

JAVA PROGRAMMING LAB. ABSTRACT In this Lab you will learn to define and invoke void and return java methods

JAVA PROGRAMMING LAB. ABSTRACT In this Lab you will learn to define and invoke void and return java methods Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Computer Programming Lab (ECOM 2114) ABSTRACT In this Lab you will learn to define and invoke void and return java methods JAVA

More information

Regular Expressions. Regular expressions are a powerful search-and-replace technique that is widely used in other environments (such as Unix and Perl)

Regular Expressions. Regular expressions are a powerful search-and-replace technique that is widely used in other environments (such as Unix and Perl) Regular Expressions Regular expressions are a powerful search-and-replace technique that is widely used in other environments (such as Unix and Perl) JavaScript started supporting regular expressions in

More information

q To develop recursive methods for recursive mathematical functions ( ).

q To develop recursive methods for recursive mathematical functions ( ). Chapter 8 Recursion CS: Java Programming Colorado State University Motivations Suppose you want to find all the files under a directory that contains a particular word. How do you solve this problem? There

More information

q To develop recursive methods for recursive mathematical functions ( ).

q To develop recursive methods for recursive mathematical functions ( ). /2/8 Chapter 8 Recursion CS: Java Programming Colorado State University Motivations Suppose you want to find all the files under a directory that contains a particular word. How do you solve this problem?

More information

Computer Programming, I. Laboratory Manual. Experiment #3. Selections

Computer Programming, I. Laboratory Manual. Experiment #3. Selections Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Experiment #3

More information

Computer Programming, I. Laboratory Manual. Experiment #5. Strings & Text Files Input

Computer Programming, I. Laboratory Manual. Experiment #5. Strings & Text Files Input Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Experiment #5

More information

3 The Building Blocks: Data Types, Literals, and Variables

3 The Building Blocks: Data Types, Literals, and Variables chapter 3 The Building Blocks: Data Types, Literals, and Variables 3.1 Data Types A program can do many things, including calculations, sorting names, preparing phone lists, displaying images, validating

More information

Decaf Language Reference Manual

Decaf Language Reference Manual Decaf Language Reference Manual C. R. Ramakrishnan Department of Computer Science SUNY at Stony Brook Stony Brook, NY 11794-4400 cram@cs.stonybrook.edu February 12, 2012 Decaf is a small object oriented

More information

Documentation Requirements Computer Science 2334 Spring 2016

Documentation Requirements Computer Science 2334 Spring 2016 Overview: Documentation Requirements Computer Science 2334 Spring 2016 These requirements are based on official Java coding conventions but have been adapted to be more appropriate to an academic environment.

More information

Variable and Data Type I

Variable and Data Type I The Islamic University of Gaza Faculty of Engineering Dept. of Computer Engineering Intro. To Computers (LNGG 1003) Lab 2 Variable and Data Type I Eng. Ibraheem Lubbad February 18, 2017 Variable is reserved

More information

Discover how to get up and running with the Java Development Environment and with the Eclipse IDE to create Java programs.

Discover how to get up and running with the Java Development Environment and with the Eclipse IDE to create Java programs. Java SE11 Development Java is the most widely-used development language in the world today. It allows programmers to create objects that can interact with other objects to solve a problem. Explore Java

More information

Eng. Mohammed S. Abdualal

Eng. Mohammed S. Abdualal Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Computer Programming Lab (ECOM 2114) Created by Eng: Mohammed Alokshiya Modified by Eng: Mohammed Abdualal Lab 3 Selections

More information

CS/CE 2336 Computer Science II

CS/CE 2336 Computer Science II S/E 2336 omputer Science II UT D Session 10 Recursion dapted from D Liang s Introduction to Java Programming, 8 th Ed 2 factorial(0) = 1; omputing Factorial factorial(n) = n*factorial(n-1); n! = n * (n-1)!

More information

Computer Programming: C++

Computer Programming: C++ The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2003 Muath i.alnabris Computer Programming: C++ Experiment #7 Arrays Part II Passing Array to a Function

More information

d-file Language Reference Manual

d-file Language Reference Manual Erwin Polio Amrita Rajagopal Anton Ushakov Howie Vegter d-file Language Reference Manual COMS 4115.001 Thursday, October 20, 2005 Fall 2005 Columbia University New York, New York Note: Much of the content

More information

Computer Programming, I. Laboratory Manual. Final Exam Solution

Computer Programming, I. Laboratory Manual. Final Exam Solution Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Final Exam Solution

More information

Javadoc. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 7

Javadoc. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 7 Javadoc Computer Science and Engineering College of Engineering The Ohio State University Lecture 7 Motivation Over the lifetime of a project, it is easy for documentation and implementation to diverge

More information

Software and Programming 1

Software and Programming 1 Software and Programming 1 Lab 1: Introduction, HelloWorld Program and use of the Debugger 17 January 2019 SP1-Lab1-2018-19.pptx Tobi Brodie (tobi@dcs.bbk.ac.uk) 1 Module Information Lectures: Afternoon

More information

1 Lexical Considerations

1 Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler

More information

Coding Guidelines. Introduction. General Points. Avoid redundant initialization/assignment

Coding Guidelines. Introduction. General Points. Avoid redundant initialization/assignment Coding Guidelines Introduction General Points Avoid redundant initialization/assignment Use of "!" instead of explicit "== true" and "== false" Anonymous inner classes. Members sort order Naming Abbreviations

More information

FRAC: Language Reference Manual

FRAC: Language Reference Manual FRAC: Language Reference Manual Justin Chiang jc4127 Kunal Kamath kak2211 Calvin Li ctl2124 Anne Zhang az2350 1. Introduction FRAC is a domain-specific programming language that enables the programmer

More information

COMP 202 Recursion. CONTENTS: Recursion. COMP Recursion 1

COMP 202 Recursion. CONTENTS: Recursion. COMP Recursion 1 COMP 202 Recursion CONTENTS: Recursion COMP 202 - Recursion 1 Recursive Thinking A recursive definition is one which uses the word or concept being defined in the definition itself COMP 202 - Recursion

More information

Variable and Data Type I

Variable and Data Type I Islamic University Of Gaza Faculty of Engineering Computer Engineering Department Lab 2 Variable and Data Type I Eng. Ibraheem Lubbad September 24, 2016 Variable is reserved a location in memory to store

More information

VENTURE. Section 1. Lexical Elements. 1.1 Identifiers. 1.2 Keywords. 1.3 Literals

VENTURE. Section 1. Lexical Elements. 1.1 Identifiers. 1.2 Keywords. 1.3 Literals VENTURE COMS 4115 - Language Reference Manual Zach Adler (zpa2001), Ben Carlin (bc2620), Naina Sahrawat (ns3001), James Sands (js4597) Section 1. Lexical Elements 1.1 Identifiers An identifier in VENTURE

More information

HAWK Language Reference Manual

HAWK Language Reference Manual HAWK Language Reference Manual HTML is All We Know Created By: Graham Gobieski, George Yu, Ethan Benjamin, Justin Chang, Jon Adelson 0. Contents 1 Introduction 2 Lexical Convetions 2.1 Tokens 2.2 Comments

More information

Java Programming with Eclipse

Java Programming with Eclipse One Introduction to Java 2 Usage of Java 3 Structure of Java 4 Flexibility of Java Programming 5 Using the Eclipse Software 6 Two Running Java in Eclipse 7 Introduction 8 Using Eclipse 9 Workspace Launcher

More information

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this

More information

Data Abstraction and Specification of ADTs

Data Abstraction and Specification of ADTs CITS2200 Data Structures and Algorithms Topic 4 Data Abstraction and Specification of ADTs Example The Reversal Problem and a non-adt solution Data abstraction Specifying ADTs Interfaces javadoc documentation

More information

Computer Programming, I. Laboratory Manual. Experiment #6. Loops

Computer Programming, I. Laboratory Manual. Experiment #6. Loops Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Experiment #6

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2005 Handout 6 Decaf Language Wednesday, September 7 The project for the course is to write a

More information

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved. Assoc. Prof. Dr. Marenglen Biba (C) 2010 Pearson Education, Inc. All rights reserved. Java application A computer program that executes when you use the java command to launch the Java Virtual Machine

More information

Problem 1: Building and testing your own linked indexed list

Problem 1: Building and testing your own linked indexed list CSCI 200 Lab 8 Implementing a Linked Indexed List In this lab, you will be constructing a linked indexed list. You ll then use your list to build and test a new linked queue implementation. Objectives:

More information

Documenting Java Code. Javadoc: The Tool and the Legend

Documenting Java Code. Javadoc: The Tool and the Legend Documenting Java Code Javadoc: The Tool and the Legend Comments in Java Regular Java comments: /* */ for programmers who must read or modify your code. One Liners : // for programmers who must read or

More information

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved. Java How to Program, 10/e Education, Inc. All Rights Reserved. Each class you create becomes a new type that can be used to declare variables and create objects. You can declare new classes as needed;

More information

CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM

CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM Objectives Defining a wellformed method to check class invariants Using assert statements to check preconditions,

More information

Java 1.8 Programming

Java 1.8 Programming One Introduction to Java 2 Usage of Java 3 Structure of Java 4 Flexibility of Java Programming 5 Two Running Java in Dos 6 Using the DOS Window 7 DOS Operating System Commands 8 Compiling and Executing

More information

Expanded Guidelines on Programming Style and Documentation

Expanded Guidelines on Programming Style and Documentation Page 1 of 5 Expanded Guidelines on Programming Style and Documentation Introduction Introduction to Java Programming, 5E Y. Daniel Liang liang@armstrong.edu Programming style deals with the appearance

More information

A Type System for Regular Expressions

A Type System for Regular Expressions A Type System for Regular Expressions Eric Spishak A senior thesis submitted in partial fulfillment of the requirements for the degree of Bachelor of Science With Departmental Honors Computer Science &

More information

Chapter 18 Recursion. Motivations

Chapter 18 Recursion. Motivations Chapter 18 Recursion CS1: Java Programming Colorado State University Original slides by Daniel Liang Modified slides by Chris Wilcox 1 Motivations Suppose you want to find all the files under a directory

More information

Introduction Programming Using Python Lecture 8. Dr. Zhang COSC 1437 Fall 2017 Nov 30, 2017

Introduction Programming Using Python Lecture 8. Dr. Zhang COSC 1437 Fall 2017 Nov 30, 2017 Introduction Programming Using Python Lecture 8 Dr. Zhang COSC 1437 Fall 2017 Nov 30, 2017 Chapter 12 Inheritance and Class Design Review Suppose you will define classes to model circles, rectangles, and

More information

Software and Programming 1

Software and Programming 1 Software and Programming 1 Lab 1: Introduction, HelloWorld Program and use of the Debugger 11 January 2018 SP1-Lab1-2017-18.pptx Tobi Brodie (tobi@dcs.bbk.ac.uk) 1 Module Information Lectures: Afternoon

More information

CSC Web Programming. Introduction to JavaScript

CSC Web Programming. Introduction to JavaScript CSC 242 - Web Programming Introduction to JavaScript JavaScript JavaScript is a client-side scripting language the code is executed by the web browser JavaScript is an embedded language it relies on its

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2010 Handout Decaf Language Tuesday, Feb 2 The project for the course is to write a compiler

More information

STUDENT LESSON A9 Recursion

STUDENT LESSON A9 Recursion STUDENT LESSON A9 Recursion Java Curriculum for AP Computer Science, Student Lesson A9 1 STUDENT LESSON A9 Recursion INTRODUCTION: Recursion is the process of a method calling itself as part of the solution

More information

The Logical Design of the Tokeniser

The Logical Design of the Tokeniser Page 1 of 21 The Logical Design of the Tokeniser Purpose 1. To split up a character string holding a RAQUEL statement expressed in linear text, into a sequence of character strings (called word tokens),

More information

CC316: Object Oriented Programming

CC316: Object Oriented Programming CC316: Object Oriented Programming Lecture 5: Strings and Text I/O - Ch 9. Dr. Manal Helal, Fall 2015. http://moodle.manalhelal.com Motivations Often you encounter the problems that involve string processing

More information

JavaCC: SimpleExamples

JavaCC: SimpleExamples JavaCC: SimpleExamples This directory contains five examples to get you started using JavaCC. Each example is contained in a single grammar file and is listed below: (1) Simple1.jj, (2) Simple2.jj, (3)

More information

JOSE LUIS JUAREZ VIVEROS com) has a. non-transferable license to use this Student Guide

JOSE LUIS JUAREZ VIVEROS com) has a. non-transferable license to use this Student Guide Module 3 Identifiers, Keywords, and Types Objectives Upon completion of this module, you should be able to: Use comments in a source program Distinguish between valid and invalid identifiers Recognize

More information

CSCI 2101 Java Style Guide

CSCI 2101 Java Style Guide CSCI 2101 Java Style Guide Fall 2017 This document describes the required style guidelines for writing Java code in CSCI 2101. Guidelines are provided for four areas of style: identifiers, indentation,

More information

Introduction to Java. Java Programs Classes, Methods, and Statements Comments Strings Escape Sequences Identifiers Keywords

Introduction to Java. Java Programs Classes, Methods, and Statements Comments Strings Escape Sequences Identifiers Keywords Introduction to Java Java Programs Classes, Methods, and Statements Comments Strings Escape Sequences Identifiers Keywords Program Errors Syntax Runtime Logic Procedural Decomposition Methods Flow of Control

More information

Initial Coding Guidelines

Initial Coding Guidelines Initial Coding Guidelines ITK 168 (Lim) This handout specifies coding guidelines for programs in ITK 168. You are expected to follow these guidelines precisely for all lecture programs, and for lab programs.

More information

ECE251 Midterm practice questions, Fall 2010

ECE251 Midterm practice questions, Fall 2010 ECE251 Midterm practice questions, Fall 2010 Patrick Lam October 20, 2010 Bootstrapping In particular, say you have a compiler from C to Pascal which runs on x86, and you want to write a self-hosting Java

More information

CS 6353 Compiler Construction Project Assignments

CS 6353 Compiler Construction Project Assignments CS 6353 Compiler Construction Project Assignments In this project, you need to implement a compiler for a language defined in this handout. The programming language you need to use is C or C++ (and the

More information

CS 351 Design of Large Programs Coding Standards

CS 351 Design of Large Programs Coding Standards CS 351 Design of Large Programs Coding Standards Brooke Chenoweth University of New Mexico Spring 2018 CS-351 Coding Standards All projects and labs must follow the great and hallowed CS-351 coding standards.

More information

Project 1. Java Control Structures 1/17/2014. Project 1 and Java Intro. Project 1 (2) To familiarize with

Project 1. Java Control Structures 1/17/2014. Project 1 and Java Intro. Project 1 (2) To familiarize with Project 1 and Java Intro Sharma Chakravarthy Information Technology Laboratory (IT Lab) Computer Science and Engineering Department The University of Texas at Arlington, Arlington, TX 76019 Email: sharma@cse.uta.edu

More information

Recursion. Recursion [Bono] 1

Recursion. Recursion [Bono] 1 Recursion Idea A few examples wishful thinking method Recursion in classes Ex: palindromes Helper functions Computational complexity of recursive functions Recursive functions with multiple calls Recursion

More information

1. a) What #include statement do you put at the top of a program that does uses cin, cout or endl?

1. a) What #include statement do you put at the top of a program that does uses cin, cout or endl? Exercises with solutions. 1. a) What #include statement do you put at the top of a program that does uses cin, cout or endl? #include b) What using statement do you always put at the top of

More information

Methods. Eng. Mohammed Abdualal

Methods. Eng. Mohammed Abdualal Islamic University of Gaza Faculty of Engineering Computer Engineering Department Computer Programming Lab (ECOM 2114) Created by Eng: Mohammed Alokshiya Modified by Eng: Mohammed Abdualal Lab 8 Methods

More information

Assignment 5. Introduction

Assignment 5. Introduction Assignment 5 Introduction The objectives of this assignment are to exercise a few advanced object oriented programming and basic data structures concepts. The first mini-goal is to understand that objects

More information

Supplement D: Expanded Guidelines on Programming Style and Documentation

Supplement D: Expanded Guidelines on Programming Style and Documentation Page 1 of 5 Introduction Supplement D: Expanded Guidelines on Programming Style and Documentation For Introduction to Java Programming Y. Daniel Liang mailto:liang@armstrong.edu Programming style deals

More information

c) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance.

c) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance. 2.1 Introduction (No questions.) 2.2 A Simple Program: Printing a Line of Text 2.1 Which of the following must every C program have? (a) main (b) #include (c) /* (d) 2.2 Every statement in C

More information

Lab # 6. Data Manipulation Language (DML)

Lab # 6. Data Manipulation Language (DML) Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4113: Lab # 6 Data Manipulation Language (DML) Eng. Haneen El-Masry December, 2014 2 Objective To be more familiar

More information

Arrays. Eng. Mohammed Abdualal

Arrays. Eng. Mohammed Abdualal Islamic University of Gaza Faculty of Engineering Computer Engineering Department Computer Programming Lab (ECOM 2114) Created by Eng: Mohammed Alokshiya Modified by Eng: Mohammed Abdualal Lab 9 Arrays

More information

Java Fundamentals p. 1 The Origins of Java p. 2 How Java Relates to C and C++ p. 3 How Java Relates to C# p. 4 Java's Contribution to the Internet p.

Java Fundamentals p. 1 The Origins of Java p. 2 How Java Relates to C and C++ p. 3 How Java Relates to C# p. 4 Java's Contribution to the Internet p. Preface p. xix Java Fundamentals p. 1 The Origins of Java p. 2 How Java Relates to C and C++ p. 3 How Java Relates to C# p. 4 Java's Contribution to the Internet p. 5 Java Applets and Applications p. 5

More information

Introduction to Python

Introduction to Python Islamic University Of Gaza Faculty of Engineering Computer Engineering Department Lab 1 Introduction to Python Eng. Ibraheem Lubbad September 17, 2016 Introduction: Python is a high-level, object-oriented

More information

Computer Programming : C++

Computer Programming : C++ The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2003 Muath i.alnabris Computer Programming : C++ Experiment #1 Basics Contents Structure of a program

More information

Eng. Mohammed Abdualal

Eng. Mohammed Abdualal Islamic University of Gaza Faculty of Engineering Computer Engineering Department Computer Programming Lab (ECOM 2114) Created by Eng: Mohammed Alokshiya Modified by Eng: Mohammed Abdualal Lab 4 Characters

More information

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines. Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of

More information

C22a: Problem Solving using Recursion

C22a: Problem Solving using Recursion CISC 3115 TY3 C22a: Problem Solving using Recursion Hui Chen Department of Computer & Information Science CUNY Brooklyn College 11/6/2018 CUNY Brooklyn College 1 Outline Characteristics of recursion Recursion

More information

The PCAT Programming Language Reference Manual

The PCAT Programming Language Reference Manual The PCAT Programming Language Reference Manual Andrew Tolmach and Jingke Li Dept. of Computer Science Portland State University September 27, 1995 (revised October 15, 2002) 1 Introduction The PCAT language

More information

6.170 Laboratory in Software Engineering Java Style Guide. Overview. Descriptive names. Consistent indentation and spacing. Page 1 of 5.

6.170 Laboratory in Software Engineering Java Style Guide. Overview. Descriptive names. Consistent indentation and spacing. Page 1 of 5. Page 1 of 5 6.170 Laboratory in Software Engineering Java Style Guide Contents: Overview Descriptive names Consistent indentation and spacing Informative comments Commenting code TODO comments 6.170 Javadocs

More information

Lab 3: Call to Order CSCI 2101 Fall 2018

Lab 3: Call to Order CSCI 2101 Fall 2018 Due: Monday, October 15, 11:59 pm Collaboration Policy: Level 1 Group Policy: Pair-Optional Lab 3: Call to Order CSCI 2101 Fall 2018 This week s lab will explore sorting, lists, and basic data analysis.

More information

Fall 2018 Discussion 8: October 24, 2018 Solutions. 1 Introduction. 2 Primitives

Fall 2018 Discussion 8: October 24, 2018 Solutions. 1 Introduction. 2 Primitives CS 6A Scheme Fall 208 Discussion 8: October 24, 208 Solutions Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write

More information

Chapter Two Bonus Lesson: JavaDoc

Chapter Two Bonus Lesson: JavaDoc We ve already talked about adding simple comments to your source code. The JDK actually supports more meaningful comments as well. If you add specially-formatted comments, you can then use a tool called

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

CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square)

CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square) CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square) Introduction This semester, through a project split into 3 phases, we are going

More information

Rule 1-3: Use white space to break a function into paragraphs. Rule 1-5: Avoid very long statements. Use multiple shorter statements instead.

Rule 1-3: Use white space to break a function into paragraphs. Rule 1-5: Avoid very long statements. Use multiple shorter statements instead. Chapter 9: Rules Chapter 1:Style and Program Organization Rule 1-1: Organize programs for readability, just as you would expect an author to organize a book. Rule 1-2: Divide each module up into a public

More information

Lab 3: Call to Order CSCI 2101 Fall 2017

Lab 3: Call to Order CSCI 2101 Fall 2017 Lab 3: Call to Order CSCI 2101 Fall 2017 Due: Part 1: Tuesday, Oct 3, 11:59 pm, Part 2: Wednesday, Oct 11, 11:59 pm Collaboration Policy: Level 1 Group Policy: Part 1: Individual, Part 2: Pair-Optional

More information

Write for your audience

Write for your audience Comments Write for your audience Program documentation is for programmers, not end users There are two groups of programmers, and they need different kinds of documentation Some programmers need to use

More information

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University 9/5/6 CS Introduction to Computing II Wayne Snyder Department Boston University Today: Arrays (D and D) Methods Program structure Fields vs local variables Next time: Program structure continued: Classes

More information

Mobile App:IT. Methods & Classes

Mobile App:IT. Methods & Classes Mobile App:IT Methods & Classes WHAT IS A METHOD? - A method is a set of code which is referred to by name and can be called (invoked) at any point in a program simply by utilizing the method's name. -

More information

Princess Nourah bint Abdulrahman University. Computer Sciences Department

Princess Nourah bint Abdulrahman University. Computer Sciences Department Princess Nourah bint Abdulrahman University 1 And use http://www.w3schools.com/ JavaScript Objectives Introduction to JavaScript Objects Data Variables Operators Types Functions Events 4 Why Study JavaScript?

More information

Lesson 1: Writing Your First JavaScript

Lesson 1: Writing Your First JavaScript JavaScript 101 1-1 Lesson 1: Writing Your First JavaScript OBJECTIVES: In this lesson you will be taught how to Use the tag Insert JavaScript code in a Web page Hide your JavaScript

More information

Java Style Guide. 1.0 General. 2.0 Visual Layout. Dr Caffeine

Java Style Guide. 1.0 General. 2.0 Visual Layout. Dr Caffeine September 25, 2002 Java Style Guide Dr Caffeine This document defines the style convention the students must follow in submitting their programs. This document is a modified version of the document originally

More information

Language Reference Manual

Language Reference Manual Espresso Language Reference Manual 10.06.2016 Rohit Gunurath, rg2997 Somdeep Dey, sd2988 Jianfeng Qian, jq2252 Oliver Willens, oyw2103 1 Table of Contents Table of Contents 1 Overview 3 Types 4 Primitive

More information

Voice Application Specification. SBString

Voice Application Specification. SBString Voice Application Specification Page 1 of 52 SBString Voice Application Specification SBString Thu, 10-Jan-2013 Voice Application Specification Page 2 of 52 SBString Revision History Revision number Change

More information

Review: Array Initializer Lists

Review: Array Initializer Lists More on Arrays Review of Arrays of ints, doubles, chars Arrays of objects Command line arguments The ArrayList class Javadoc Review Lecture 8 notes and L&L 7.1 7.2 Reading for this lecture: L&L 7.3 7.7,

More information

Writing Functions. Reading: Dawson, Chapter 6. What is a function? Function declaration and parameter passing Return values Objects as parameters

Writing Functions. Reading: Dawson, Chapter 6. What is a function? Function declaration and parameter passing Return values Objects as parameters What is a function? Function declaration and parameter passing Return values Objects as parameters Reading: Writing Functions Dawson, Chapter 6 Abstraction Data scoping Encapsulation Modules Recursion

More information

Converting a Lowercase Letter Character to Uppercase (Or Vice Versa)

Converting a Lowercase Letter Character to Uppercase (Or Vice Versa) Looping Forward Through the Characters of a C String A lot of C string algorithms require looping forward through all of the characters of the string. We can use a for loop to do that. The first character

More information