Chapter 6: Small Java Programs Bradley Kjell (Revised 6/21/2010)

Size: px
Start display at page:

Download "Chapter 6: Small Java Programs Bradley Kjell (Revised 6/21/2010)"

Transcription

1 Chapter 6: Small Java Programs Bradley Kjell (Revised 6/21/2010) Chapter Topics: Small example programs Names for source files and class files Syntax errors Bugs The Edit, Compile, and Run cycle Matching braces Neat indenting The previous chapter discussed the mechanics of creating and running a Java program. This chapter is an overview of Java using the example program from that chapter. QUESTION 1: (Review:) What role in Java programming does each of the following files play? Source code file Bytecode file Used by permission. Page 1 of 26

2 Source code file: o a text file in the Java language created by a programmer with a text editor Bytecode file: o a file of machine language for the Java virtual machine created by a Java compiler Example Source Program Above is the source program (source file) from the previous chapter. The purpose of this program is to type the characters Hello World! on the monitor. The file must be named Hello.java to match the name of the class. On most computer systems, the upper and lower case characters of the file name are important. (So if the file is named hello.java with a small h it will not work). On all computers, upper and lower case inside the program are important. The first line class Hello says that this source program defines a class called Hello. A class is a section of a program. (A better definition will come later on in these notes.) Small programs often consist of just one class. When the program is compiled, the compiler will make a file of bytecodes called Hello.class. QUESTION 2: Here is the first line of another Java program: class AddUpNumbers 1. What should the source file be named? 2. What is the name of the bytecode file the compiler creates? Used by permission. Page 2 of 26

3 What should the source file be named? o AddUpNumbers.java What is the name of the bytecode file the compiler creates? o AddUpNumbers.class Identifiers and Reserved Words Most classes contain many more lines than this one. Everything that makes up a class is placed between the first brace { and its matching last brace }. The name of the class (and therefore the name of the file) is up to you. In programming, the name for something like a class is called an identifier. An identifier consists of alphabetical characters and digits. The first character must be alphabetical, the remaining characters can be mixed alphabetic characters and digits (plus the two characters '_' and '$' underscore and dollar sign). No spaces are allowed inside the name. Chapter nine discusses this in more detail. Usually a class name starts with a capital letter, but this is not required. A source file should always end with.java in lower case. A reserved word is a word like class that has a special meaning to the system. For example, class means that a definition of a class immediately follows. You must use reserved words only for their intended purpose. (For example, you can't use the word class for any other purpose than defining a class.) QUESTION 3: Which of the following look like good identifiers? 1. ExcitingGame 2. Lady Luck 3. x32 4. lastchance 5. x/y Used by permission. Page 3 of 26

4 1. ExcitingGame OK: mixed upper and lower case is allowed 2. Lady Luck BAD: no spaces allowed inside an identifier 3. x32 OK: identifiers must start with an alphabetical character, but the rest can be digits. 4. lastchance OK: class names usually start with a capital, but identifiers don't have to. 5. x/y BAD: the slash is not allowed inside an identifier Between the Braces The small Java programs in this chapter all look like this: class Hello { } Everything that a program does is described between the first brace and the final brace of a class. To start with, we will have only one class per source code file, but in later chapters there may be several classes per source code file. The example program writes Hello World! to the monitor. It looks like a lot of program for such a little task! But, usually, programs are much longer and the details you see here help to keep them organized. The line public static void main ( String[] args ) shows where the program starts running. The word main means that this is the main method where the Java virtual machine starts running the program. The main method must start with this line, and all of its parts must be present. Wherever there is one space it is OK to have any number of spaces. The spaces surrounding the Used by permission. Page 4 of 26

5 parentheses in the third line are not required. The fifth line shows parentheses not surrounded by spaces (but you could put them in). QUESTION 4: Is the following acceptable? public static void main(string[] args ) Used by permission. Page 5 of 26

6 public static void main(string[] args ) The Java compiler would accept the line. But it looks sloppy to human eyes. println() There are rules about where spaces may be used, and optional style rules about how to make a program look nice. Rather than look at a list of rules, look at some Java programs and pick up the rules by example. The main method of this program consists of a single statement: System.out.println("Hello World!"); This statement writes the characters inside the quotation marks to the monitor of the computer system. (The quotation marks are not written.) A statement in a programming language is a command for the computer to do something. It is like a sentence of the language. A statement in Java is followed by a semicolon. Methods are built out of statements. The statements in a method are placed between braces { and } as in this example. The part "Hello World!" is called a string. A string is a sequence of characters. This program writes a string to the monitor and then stops. QUESTION 5: (Review: ) Say that the file Hello.java contains the example program. The file is contained in the subdirectory C:\Temp on the hard disk. In order to run it, what two things must be done? Used by permission. Page 6 of 26

7 (1) The program must be compiled into bytecode with the Java compiler, then (2) run using the Java interpreter. Review of Running a Java Program Copy and paste the example program into a text editor (like Notepad or Crimson), and then save it to a file called Hello.java in the current directory. (Microsoft calls "directories" by the name "folders".) To run the program, check that the default directory of the command interpreter contains the source file. Do this by using the command DIR *.java to list the files in the directory. One of the files should be Hello.java. To see all the files, just type the command DIR. If you don't see the source file, use the Change Directory command CD to get to the correct subdirectory. To compile the source file (thereby producing a file of bytecodes) enter the command javac Hello.java. Finally, to run it, enter the command java Hello. Used by permission. Page 7 of 26

8 QUESTION 6: What is the command that runs the Java compiler? What is the command that runs the Java interpreter? Used by permission. Page 8 of 26

9 What is the command that runs the Java compiler? o javac What is the command that runs the Java interpreter? o Java Syntax Errors It is likely that you will do something wrong. Here is the sample program with a deliberate error: QUESTION 7: What is the error? (Don't spend much time looking; it is really small.) Used by permission. Page 9 of 26

10 The reserved word "class" has been changed to "Class" with a capital "C". A Capital Mistake The reserved word "class" has been changed to "Class" with a capital "C". This is called a syntax error. A syntax error is a "grammatical error" in using the programming language. Here is what happens when the mistaken program is compiled: The compiler tried to translate the source code into bytecode but got confused when it got to a capital "C" it did not expect. The error message is not very clear. They never are. But at least it shows where the compiler got confused. The compiler did not create a new bytecode file because it stopped translating when it got to the error. QUESTION 8: To fix this error and run the program what must you do? Used by permission. Page 10 of 26

11 To fix the error, use a text editor to fix the source file. Fixing Errors Usually you will have two windows open on your computer: one for a text editor (such as Notepad or Crimson) and one for the command interpreter. To fix the syntax error, change the "C" to a "c" and save the file. Now use javac to compile the source file, and if there are no errors, use java to run it. QUESTION 9: If you forget to save the file after making the change, and then enter the command javac Hello.java, what will happen? Used by permission. Page 11 of 26

12 You would compile the old, uncorrected version of the source file on hard disk and get the same error message. When you use a text editor you change the source program that is in main memory. If you don't save your changes, the file on disk does not change. The compiler javac uses the file that is currently on the hard disk. This is a common mistake. Edit, Compile, Run Cycle Until your program runs correctly: 1. Edit the program (the source file). 2. Save the program to the hard disk with the "Save" or "Save As" command of the editor. 3. Compile the program with the javac command. 4. If there are syntax errors, go back to step Run the program with the java command. 6. If there are bugs, go back to step When it runs correctly, quit. This is called the "edit-compile-and-run" cycle. Expect to go through it many times per program. A Java development environment like Eclipse or BlueJ is more sophisticated, but you still go through the same fundamental cycle. QUESTION 10: If a source program compiles correctly in step 3, does that mean that it will run correctly? Used by permission. Page 12 of 26

13 No. Bugs Just because a program compiles and runs does not mean that it is correct. For example, say that your assignment is to create a program that writes "Hello World!" on the computer monitor. But you write the above program. When a program compiles without any syntax errors, but does not perform as expected when it runs, the program is said to have a bug. QUESTION 11: Will this program compile without syntax errors? Will this program run? Does the program meet the assignment? Used by permission. Page 13 of 26

14 Will this program compile without syntax errors? o Yes. Will this program run? o Yes. Does the program meet the assignment? o No it has a bug. Longer Example Program Usually bugs are much more difficult to find than the one in this program. The longer a program is, the more bugs it is likely to have, and the more difficult it is to find them. It is a good idea to practice with short programs where syntax errors and bugs are more easily seen before moving on to longer programs. Above is a somewhat longer example program. The program is much like the "Hello World!" program but the main method has more statements inside of it. Create this program with a text editor, compile and run it. Save the program in a file called Emily.java. The compiler will create a bytecode file called Emily.class. QUESTION 12: What does this program write to the monitor when it is run? Used by permission. Page 14 of 26

15 Each System.out.println statement writes out the characters inside the quote marks: A bird came down the walk He did not know I saw; He bit an angle- worm in halves And ate the fellow, raw. Another Example Now say that your assignment is to create a program that writes the following to the computer monitor: On a withered branch A crow has just alighted: Nightfall in autumn. Above is the program that is to perform this task, but with some blank boxes for you to fill in. The extra lines between program statements don't hurt. Blank lines often make a program easier to read. QUESTION 13: Fill in the blanks of the program. Used by permission. Page 15 of 26

16 The completed program is given below: Finished Program Here is the completed program. Be sure that you put the quote marks where they belong. If you forget just one of them, the compiler will become confused and will not translate your program! If you have been creating the example programs and compiling and running them, you may have noticed that spaces and new lines in the program are not critical. (However, you can't put spaces in the middle of a word, and spaces inside the quote marks do matter.) For example, the following version of the program will compile correctly and will do exactly the same thing as the original version when it is run: The compiler does not "see" the two dimensional layout of the program. It regards the program as a stream of characters, one following the other. Used by permission. Page 16 of 26

17 However, humans are sensitive to the layout of text, and it is important to be neat and consistent when you create a source file. Although the second version of the program runs correctly, it is much harder for a person to understand. QUESTION 14: If there were a slight mistake in the poorly laid-out program, would it be easy to find? Used by permission. Page 17 of 26

18 No. Everything is so confused, a slight mistake is easily overlooked. Comments A comment is a note written to a human reader of a program. A comment starts with the two characters // (slash slash). Those characters and everything that follows them on that one line are ignored by the java compiler. The program compiles and runs exactly the same as before. The green color in the above program was added by hand. However, most program editors (such as Crimson and Notepad++) are smart enough to recognize comments and will display them in color. Of course, the text file contains only the characters you have entered. QUESTION 15: Are comments included in the bytecode translation of a Java program? Used by permission. Page 18 of 26

19 No. Remember, the compiler completely ignores them. Comments are just for humans. Many Comments Comments can be placed after a program statement to explain what it does, as here. As with all comments, the // and everything after it on that line are ignored by the compiler. The program statement in the start of the line is not affected by the comment. QUESTION 16: Would you ever want to write an entire paragraph of comments? Used by permission. Page 19 of 26

20 Yes. Many-line Comments Often you want to write a comment that spans several lines, as above. With this style of comment, everything between the two characters /* and the two chracters */ are ignored by the compiler. The / and the * must not have any character between them. There can be many lines of comments between the /* pair and the */ pair. The /* and the */ can start and stop anywhere on a line. Everything between the pair is a comment ignored by the compiler. Used by permission. Page 20 of 26

21 QUESTION 17: Is the following correct? Used by permission. Page 21 of 26

22 Yes, although it is ugly and not commonly done. Commenting Out Code Comments are useful for debugging. For example, the above program has a syntax error. Let's say that you are having problems finding the error. One way to narrow down the problem is to remove some of the code from consideration by turning it into a comment. Compile and run the program. If the modified program works as expected, the error must be in the commented section. Gradually decrease the commented section until you find the error. QUESTION 18: Why would you ever want to use comments to help a person understand your program? Used by permission. Page 22 of 26

23 The person might be you. Comments are often notes to yourself about what something is, or why you did something the way you did. Braces Examine the program. For every left brace { there is a right brace } that matches. Usually there will be sets of matching braces inside other sets of matching braces. The first brace in a class (a left brace) will match the last brace in that class (a right brace). A brace can match just one other brace. Use indenting to show how the braces match (and thereby show the logic of the program). Look at the example. Increase the indenting by two spaces for statements inside a left and right brace. If another pair of braces is nested within those braces, increase the indenting for the statements they contain by another two spaces. Line up the braces vertically. There are many styles of laying out a program. If you are reading a printed text book in addition to these notes, it may use a different style. QUESTION 19: Mentally circle the matching braces in the above program. Used by permission. Page 23 of 26

24 Used by permission. Page 24 of 26

25 The matching braces are indicated in color, below: Matching Pairs Notice that in addition to pairs of braces that match, there are pairs of parentheses (), and pairs of brackets [] that match. Large programs will have many of these matching pairs, which are used to group sections of the program together. Format your program as you write it. This helps you see the logic you are creating, and is a tremendous help in programming. Text editors intended for program creation (called program editors) and more sophisticated programming environments always have ways to show matching braces. This is really valuable. You should definitely learn to use this feature with whatever editor or environment you are using. QUESTION 20: If a program is missing just one brace, will it compile? Used by permission. Page 25 of 26

26 No. But if you have been neat, it is easy to find where the missing brace should go. End of the Chapter Brace yourself! you have reached the end of the chapter. You may wish to review the following. Click on a subject that interests you to go to where it was discussed. Hello World example program. methods and classes. Syntax Errors. Edit, compile, and run cycle. Program bugs. Importance of spaces and newlines in programs. Comments Multiline Comments Matching braces. The next chapter will discuss a way to run the programs in these notes without actually typing them in, and discusses details of using Notepad. Used by permission. Page 26 of 26

CS 106 Introduction to Computer Science I

CS 106 Introduction to Computer Science I CS 106 Introduction to Computer Science I 01 / 21 / 2014 Instructor: Michael Eckmann Today s Topics Introduction Homework assignment Review the syllabus Review the policies on academic dishonesty and improper

More information

1001ICT Introduction To Programming Lecture Notes

1001ICT Introduction To Programming Lecture Notes 1001ICT Introduction To Programming Lecture Notes School of Information and Communication Technology Griffith University Semester 2, 2015 1 3 A First MaSH Program In this section we will describe a very

More information

Moving from CS 61A Scheme to CS 61B Java

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

More information

LAB4 Making Classes and Objects

LAB4 Making Classes and Objects LAB4 Making Classes and Objects Objective The main objective of this lab is class creation, how its constructer creation, object creation and instantiation of objects. We will use the definition pane to

More information

Installing Java. Table of contents

Installing Java. Table of contents Table of contents 1 Jargon...3 2 Introduction...4 3 How to install the JDK...4 3.1 Microsoft Windows 95... 4 3.1.1 Installing the JDK... 4 3.1.2 Setting the Path Variable...5 3.2 Microsoft Windows 98...

More information

Introduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved.

Introduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved. 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

More information

Simple Java Applications

Simple Java Applications Chapter 2 Simple Java Applications 2.1 An Application and its Architecture 2.2 How to Build and Execute an Application 2.2.1 Using an IDE 2.2.2 Using the JDK 2.3 How the Application Works 2.3.1 An Execution

More information

Week 2 Practical Objects and Turtles

Week 2 Practical Objects and Turtles Week 2 Practical Objects and Turtles Aims and Objectives Your aim in this practical is: to practise the creation and use of objects in Java By the end of this practical you should be able to: create objects

More information

Install Java Development Kit (JDK) 1.8 http://www.oracle.com/technetwork/java/javase/downloads/index.html

Install Java Development Kit (JDK) 1.8 http://www.oracle.com/technetwork/java/javase/downloads/index.html CS 259: Data Structures with Java Hello World with the IntelliJ IDE Instructor: Joel Castellanos e-mail: joel.unm.edu Web: http://cs.unm.edu/~joel/ Office: Farris Engineering Center 319 8/19/2015 Install

More information

Programming in Access VBA

Programming in Access VBA PART I Programming in Access VBA In this part, you will learn all about how Visual Basic for Applications (VBA) works for Access 2010. A number of new VBA features have been incorporated into the 2010

More information

Java CPD (I) Frans Coenen Department of Computer Science

Java CPD (I) Frans Coenen Department of Computer Science Java CPD (I) Frans Coenen Department of Computer Science Content Session 1, 12:45-14:30 (First Java Programme, Inheritance, Arithmetic) Session 2, 14:45-16:45 (Input and Programme Constructs) Materials

More information

Introduction to programming

Introduction to programming Unit 1 Introduction to programming Summary Architecture of a computer Programming languages Program = objects + operations First Java program Writing, compiling, and executing a program Program errors

More information

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java

More information

Third AP Edition. Object-Oriented Programming and Data Structures. Maria Litvin. Gary Litvin. Phillips Academy, Andover, Massachusetts

Third AP Edition. Object-Oriented Programming and Data Structures. Maria Litvin. Gary Litvin. Phillips Academy, Andover, Massachusetts Third AP Edition Object-Oriented Programming and Data Structures Maria Litvin Phillips Academy, Andover, Massachusetts Gary Litvin Skylight Software, Inc. Skylight Publishing Andover, Massachusetts Skylight

More information

Topics. Parts of a Java Program. Topics (2) CS 146. Introduction To Computers And Java Chapter Objectives To understand:

Topics. Parts of a Java Program. Topics (2) CS 146. Introduction To Computers And Java Chapter Objectives To understand: Introduction to Programming and Algorithms Module 2 CS 146 Sam Houston State University Dr. Tim McGuire Introduction To Computers And Java Chapter Objectives To understand: the meaning and placement of

More information

Getting Started with Command Prompts

Getting Started with Command Prompts Getting Started with Command Prompts Updated March, 2013 Some courses such as TeenCoder : Java Programming will ask the student to perform tasks from a command prompt (Windows) or Terminal window (Mac

More information

Appendix A Using the Java Compiler

Appendix A Using the Java Compiler Appendix A Using the Java Compiler 1. Download the Java Development Kit from Sun: a. Go to http://java.sun.com/j2se/1.4.2/download.html b. Download J2SE v1.4.2 (click the SDK column) 2. Install Java. Simply

More information

WA2099 Introduction to Java using RAD 8.0 EVALUATION ONLY. Student Labs. Web Age Solutions Inc.

WA2099 Introduction to Java using RAD 8.0 EVALUATION ONLY. Student Labs. Web Age Solutions Inc. WA2099 Introduction to Java using RAD 8.0 Student Labs Web Age Solutions Inc. 1 Table of Contents Lab 1 - The HelloWorld Class...3 Lab 2 - Refining The HelloWorld Class...20 Lab 3 - The Arithmetic Class...25

More information

Word basics. Before you begin. What you'll learn. Requirements. Estimated time to complete:

Word basics. Before you begin. What you'll learn. Requirements. Estimated time to complete: Word basics Word is a powerful word processing and layout application, but to use it most effectively, you first have to understand the basics. This tutorial introduces some of the tasks and features that

More information

Computer Programming In QBasic

Computer Programming In QBasic Computer Programming In QBasic Name: Class ID. Computer# Introduction You've probably used computers to play games, and to write reports for school. It's a lot more fun to create your own games to play

More information

First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science

First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca

More information

LAB 1. Familiarization of Rational Rose Environment And UML for small Java Application Development

LAB 1. Familiarization of Rational Rose Environment And UML for small Java Application Development LAB 1 Familiarization of Rational Rose Environment And UML for small Java Application Development OBJECTIVE AND BACKGROUND The purpose of this first UML lab is to familiarize programmers with Rational

More information

2 The first program: Little Crab

2 The first program: Little Crab 2 The first program: Little Crab topics: concepts: writing code: movement, turning, reacting to the screen edges source code, method call, parameter, sequence, if statement In the previous chapter, we

More information

Notepad++ The COMPSCI 101 Text Editor for Windows. What is a text editor? Install Python 3

Notepad++ The COMPSCI 101 Text Editor for Windows. What is a text editor? Install Python 3 Notepad++ The COMPSCI 101 Text Editor for Windows The text editor that we will be using in the Computer Science labs for creating our Python programs is called Notepad++ and http://notepad-plus-plus.org

More information

Online Chapter B. Running Programs

Online Chapter B. Running Programs Online Chapter B Running Programs This online chapter explains how you can create and run Java programs without using an integrated development environment (an environment like JCreator). The chapter also

More information

Introduction to Java

Introduction to Java Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high

More information

Chapter 2. Making Shapes

Chapter 2. Making Shapes Chapter 2. Making Shapes Let's play turtle! You can use your Pencil Turtle, you can use yourself, or you can use some of your friends. In fact, why not try all three? Rabbit Trail 4. Body Geometry Can

More information

Programming Languages CIS 443

Programming Languages CIS 443 Course Objectives Programming Languages CIS 443 0.1 Lexical analysis Syntax Semantics Functional programming Variable lifetime and scoping Parameter passing Object-oriented programming Continuations Exception

More information

CS 1133, LAB 2: FUNCTIONS AND TESTING http://www.cs.cornell.edu/courses/cs1133/2015fa/labs/lab02.pdf

CS 1133, LAB 2: FUNCTIONS AND TESTING http://www.cs.cornell.edu/courses/cs1133/2015fa/labs/lab02.pdf CS 1133, LAB 2: FUNCTIONS AND TESTING http://www.cs.cornell.edu/courses/cs1133/2015fa/labs/lab02.pdf First Name: Last Name: NetID: The purpose of this lab is to help you to better understand functions:

More information

The VB development environment

The VB development environment 2 The VB development environment This chapter explains: l how to create a VB project; l how to manipulate controls and their properties at design-time; l how to run a program; l how to handle a button-click

More information

2: Entering Data. Open SPSS and follow along as your read this description.

2: Entering Data. Open SPSS and follow along as your read this description. 2: Entering Data Objectives Understand the logic of data files Create data files and enter data Insert cases and variables Merge data files Read data into SPSS from other sources The Logic of Data Files

More information

Java Crash Course Part I

Java Crash Course Part I Java Crash Course Part I School of Business and Economics Institute of Information Systems HU-Berlin WS 2005 Sebastian Kolbe skolbe@wiwi.hu-berlin.de Overview (Short) introduction to the environment Linux

More information

3. Add and delete a cover page...7 Add a cover page... 7 Delete a cover page... 7

3. Add and delete a cover page...7 Add a cover page... 7 Delete a cover page... 7 Microsoft Word: Advanced Features for Publication, Collaboration, and Instruction For your MAC (Word 2011) Presented by: Karen Gray (kagray@vt.edu) Word Help: http://mac2.microsoft.com/help/office/14/en-

More information

The first program: Little Crab

The first program: Little Crab CHAPTER 2 The first program: Little Crab topics: concepts: writing code: movement, turning, reacting to the screen edges source code, method call, parameter, sequence, if-statement In the previous chapter,

More information

Sample Table. Columns. Column 1 Column 2 Column 3 Row 1 Cell 1 Cell 2 Cell 3 Row 2 Cell 4 Cell 5 Cell 6 Row 3 Cell 7 Cell 8 Cell 9.

Sample Table. Columns. Column 1 Column 2 Column 3 Row 1 Cell 1 Cell 2 Cell 3 Row 2 Cell 4 Cell 5 Cell 6 Row 3 Cell 7 Cell 8 Cell 9. Working with Tables in Microsoft Word The purpose of this document is to lead you through the steps of creating, editing and deleting tables and parts of tables. This document follows a tutorial format

More information

Getting Started with WebSite Tonight

Getting Started with WebSite Tonight Getting Started with WebSite Tonight WebSite Tonight Getting Started Guide Version 3.0 (12.2010) Copyright 2010. All rights reserved. Distribution of this work or derivative of this work is prohibited

More information

Custom Linetypes (.LIN)

Custom Linetypes (.LIN) Custom Linetypes (.LIN) AutoCAD provides the ability to create custom linetypes or to adjust the linetypes supplied with the system during installation. Linetypes in AutoCAD can be classified into two

More information

Part I. The Picture class

Part I. The Picture class CS 161 LAB 5 This lab will have two parts. In the first part, we will create a class to automate the drawing of the robot from the second lab. For the second part, we will begin a ClunkyCalculator class

More information

Chapter 3. Input and output. 3.1 The System class

Chapter 3. Input and output. 3.1 The System class Chapter 3 Input and output The programs we ve looked at so far just display messages, which doesn t involve a lot of real computation. This chapter will show you how to read input from the keyboard, use

More information

Using Karel with Eclipse

Using Karel with Eclipse Mehran Sahami Handout #6 CS 106A September 23, 2015 Using Karel with Eclipse Based on a handout by Eric Roberts Once you have downloaded a copy of Eclipse as described in Handout #5, your next task is

More information

Lab 1A. Create a simple Java application using JBuilder. Part 1: make the simplest Java application Hello World 1. Start Jbuilder. 2.

Lab 1A. Create a simple Java application using JBuilder. Part 1: make the simplest Java application Hello World 1. Start Jbuilder. 2. Lab 1A. Create a simple Java application using JBuilder In this lab exercise, we ll learn how to use a Java integrated development environment (IDE), Borland JBuilder 2005, to develop a simple Java application

More information

How to Install Java onto your system

How to Install Java onto your system How to Install Java onto your system 1. In your browser enter the URL: Java SE 2. Choose: Java SE Downloads Java Platform (JDK) 7 jdk-7- windows-i586.exe. 3. Accept the License Agreement and choose the

More information

A Short Introduction to Writing Java Code. Zoltán Majó

A Short Introduction to Writing Java Code. Zoltán Majó A Short Introduction to Writing Java Code Zoltán Majó Outline Simple Application: Hello World Compiling Programs Manually Using an IDE Useful Resources Outline Simple Application: Hello World Compiling

More information

AppendixA1A1. Java Language Coding Guidelines. A1.1 Introduction

AppendixA1A1. Java Language Coding Guidelines. A1.1 Introduction AppendixA1A1 Java Language Coding Guidelines A1.1 Introduction This coding style guide is a simplified version of one that has been used with good success both in industrial practice and for college courses.

More information

Chapter 1 Java Program Design and Development

Chapter 1 Java Program Design and Development presentation slides for JAVA, JAVA, JAVA Object-Oriented Problem Solving Third Edition Ralph Morelli Ralph Walde Trinity College Hartford, CT published by Prentice Hall Java, Java, Java Object Oriented

More information

GCU STYLE TUTORIAL - PART ONE - INTRODUCTION TO WRITING STYLES

GCU STYLE TUTORIAL - PART ONE - INTRODUCTION TO WRITING STYLES GCU STYLE TUTORIAL - PART ONE - INTRODUCTION TO WRITING STYLES Hello and welcome to Grand Canyon University s GCU Style Tutorial. This tutorial will contain two parts, the first addressing the purpose

More information

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

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

More information

Hypercosm. Studio. www.hypercosm.com

Hypercosm. Studio. www.hypercosm.com Hypercosm Studio www.hypercosm.com Hypercosm Studio Guide 3 Revision: November 2005 Copyright 2005 Hypercosm LLC All rights reserved. Hypercosm, OMAR, Hypercosm 3D Player, and Hypercosm Studio are trademarks

More information

Installing Java (Windows) and Writing your First Program

Installing Java (Windows) and Writing your First Program Appendix Installing Java (Windows) and Writing your First Program We will be running Java from the command line and writing Java code in Notepad++ (or similar). The first step is to ensure you have installed

More information

ECE 122. Engineering Problem Solving with Java

ECE 122. Engineering Problem Solving with Java ECE 122 Engineering Problem Solving with Java Introduction to Electrical and Computer Engineering II Lecture 1 Course Overview Welcome! What is this class about? Java programming somewhat software somewhat

More information

The Windows Command Prompt: Simpler and More Useful Than You Think

The Windows Command Prompt: Simpler and More Useful Than You Think The Windows Command Prompt: Simpler and More Useful Than You Think By Ryan Dube When most people think of the old DOS command prompt window that archaic, lingering vestige of computer days gone by they

More information

Manual For Using the NetBeans IDE

Manual For Using the NetBeans IDE 1 Manual For Using the NetBeans IDE The content of this document is designed to help you to understand and to use the NetBeans IDE for your Java programming assignments. This is only an introductory presentation,

More information

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives Introduction to Programming and Algorithms Module 1 CS 146 Sam Houston State University Dr. Tim McGuire Module Objectives To understand: the necessity of programming, differences between hardware and software,

More information

CMPT 183 Foundations of Computer Science I

CMPT 183 Foundations of Computer Science I Computer Science is no more about computers than astronomy is about telescopes. -Dijkstra CMPT 183 Foundations of Computer Science I Angel Gutierrez Fall 2013 A few questions Who has used a computer today?

More information

File by OCR Manual. Updated December 9, 2008

File by OCR Manual. Updated December 9, 2008 File by OCR Manual Updated December 9, 2008 edocfile, Inc. 2709 Willow Oaks Drive Valrico, FL 33594 Phone 813-413-5599 Email sales@edocfile.com www.edocfile.com File by OCR Please note: This program is

More information

Selecting Features by Attributes in ArcGIS Using the Query Builder

Selecting Features by Attributes in ArcGIS Using the Query Builder Helping Organizations Succeed with GIS www.junipergis.com Bend, OR 97702 Ph: 541-389-6225 Fax: 541-389-6263 Selecting Features by Attributes in ArcGIS Using the Query Builder ESRI provides an easy to use

More information

Using Eclipse to Run Java Programs

Using Eclipse to Run Java Programs Using Eclipse to Run Java Programs Downloading and Installing Eclipse Here s how: 1. Visit www.eclipse.org. 2. On that Web site, follow the links for downloading Eclipse. Be sure to pick the version that

More information

A Java Crib Sheet. First: Find the Command Line

A Java Crib Sheet. First: Find the Command Line A Java Crib Sheet Unlike JavaScript, which is pretty much ready-to-go on any computer with a modern Web browser, Java might be a more complex affair However, logging some time with Java can be fairly valuable,

More information

CSE 452: Programming Languages. Acknowledgements. Contents. Java and its Evolution

CSE 452: Programming Languages. Acknowledgements. Contents. Java and its Evolution CSE 452: Programming Languages Java and its Evolution Acknowledgements Rajkumar Buyya 2 Contents Java Introduction Java Features How Java Differs from other OO languages Java and the World Wide Web Java

More information

Basic Website Maintenance Tutorial*

Basic Website Maintenance Tutorial* Basic Website Maintenance Tutorial* Introduction You finally have your business online! This tutorial will teach you the basics you need to know to keep your site updated and working properly. It is important

More information

Code::Blocks Student Manual

Code::Blocks Student Manual Code::Blocks Student Manual Lawrence Goetz, Network Administrator Yedidyah Langsam, Professor and Theodore Raphan, Distinguished Professor Dept. of Computer and Information Science Brooklyn College of

More information

Anyone Can Learn PROC TABULATE

Anyone Can Learn PROC TABULATE Paper 60-27 Anyone Can Learn PROC TABULATE Lauren Haworth, Genentech, Inc., South San Francisco, CA ABSTRACT SAS Software provides hundreds of ways you can analyze your data. You can use the DATA step

More information

1) Which of the following is a constant, according to Java naming conventions? a. PI b. Test c. x d. radius

1) Which of the following is a constant, according to Java naming conventions? a. PI b. Test c. x d. radius Programming Concepts Practice Test 1 1) Which of the following is a constant, according to Java naming conventions? a. PI b. Test c. x d. radius 2) Consider the following statement: System.out.println("1

More information

Windows 95. 2a. Place the pointer on Programs. Move the pointer horizontally to the right into the next window.

Windows 95. 2a. Place the pointer on Programs. Move the pointer horizontally to the right into the next window. Word Processing Microsoft Works Windows 95 The intention of this section is to instruct basic word processing skills such as creating, editing, formatting, saving and closing a new document. Microsoft

More information

AP Computer Science Java Mr. Clausen Program 9A, 9B

AP Computer Science Java Mr. Clausen Program 9A, 9B AP Computer Science Java Mr. Clausen Program 9A, 9B PROGRAM 9A I m_sort_of_searching (20 points now, 60 points when all parts are finished) The purpose of this project is to set up a program that will

More information

How to use the Eclipse IDE for Java Application Development

How to use the Eclipse IDE for Java Application Development How to use the Eclipse IDE for Java Application Development Java application development is supported by many different tools. One of the most powerful and helpful tool is the free Eclipse IDE (IDE = Integrated

More information

Chapter One Introduction to Programming

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

More information

Lecture 5: Java Fundamentals III

Lecture 5: Java Fundamentals III Lecture 5: Java Fundamentals III School of Science and Technology The University of New England Trimester 2 2015 Lecture 5: Java Fundamentals III - Operators Reading: Finish reading Chapter 2 of the 2nd

More information

Microsoft Word 2011: Create a Table of Contents

Microsoft Word 2011: Create a Table of Contents Microsoft Word 2011: Create a Table of Contents Creating a Table of Contents for a document can be updated quickly any time you need to add or remove details for it will update page numbers for you. A

More information

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1 The Java Series Java Essentials I What is Java? Basic Language Constructs Slide 1 What is Java? A general purpose Object Oriented programming language. Created by Sun Microsystems. It s a general purpose

More information

Word 2010: The Basics Table of Contents THE WORD 2010 WINDOW... 2 SET UP A DOCUMENT... 3 INTRODUCING BACKSTAGE... 3 CREATE A NEW DOCUMENT...

Word 2010: The Basics Table of Contents THE WORD 2010 WINDOW... 2 SET UP A DOCUMENT... 3 INTRODUCING BACKSTAGE... 3 CREATE A NEW DOCUMENT... Word 2010: The Basics Table of Contents THE WORD 2010 WINDOW... 2 SET UP A DOCUMENT... 3 INTRODUCING BACKSTAGE... 3 CREATE A NEW DOCUMENT... 4 Open a blank document... 4 Start a document from a template...

More information

Java Basics: Data Types, Variables, and Loops

Java Basics: Data Types, Variables, and Loops Java Basics: Data Types, Variables, and Loops If debugging is the process of removing software bugs, then programming must be the process of putting them in. - Edsger Dijkstra Plan for the Day Variables

More information

Creating trouble-free numbering in Microsoft Word

Creating trouble-free numbering in Microsoft Word Creating trouble-free numbering in Microsoft Word This note shows you how to create trouble-free chapter, section and paragraph numbering, as well as bulleted and numbered lists that look the way you want

More information

Quick Tricks for Multiplication

Quick Tricks for Multiplication Quick Tricks for Multiplication Why multiply? A computer can multiply thousands of numbers in less than a second. A human is lucky to multiply two numbers in less than a minute. So we tend to have computers

More information

MLA Format Example and Guidelines

MLA Format Example and Guidelines MLA Format Example and Guidelines Fleming 1 John Fleming Professor Daniels ENGL 1301 One-inch margins on all sides. EVERYTHING double spaced. EVERYTHING in Times New Roman 12 pt. font size. For more details

More information

PHP Debugging. Draft: March 19, 2013 2013 Christopher Vickery

PHP Debugging. Draft: March 19, 2013 2013 Christopher Vickery PHP Debugging Draft: March 19, 2013 2013 Christopher Vickery Introduction Debugging is the art of locating errors in your code. There are three types of errors to deal with: 1. Syntax errors: When code

More information

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

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

More information

Exercise 1: Python Language Basics

Exercise 1: Python Language Basics Exercise 1: Python Language Basics In this exercise we will cover the basic principles of the Python language. All languages have a standard set of functionality including the ability to comment code,

More information

Adobe Conversion Settings in Word. Section 508: Why comply?

Adobe Conversion Settings in Word. Section 508: Why comply? It s the right thing to do: Adobe Conversion Settings in Word Section 508: Why comply? 11,400,000 people have visual conditions not correctible by glasses. 6,400,000 new cases of eye disease occur each

More information

Perl in a nutshell. First CGI Script and Perl. Creating a Link to a Script. print Function. Parsing Data 4/27/2009. First CGI Script and Perl

Perl in a nutshell. First CGI Script and Perl. Creating a Link to a Script. print Function. Parsing Data 4/27/2009. First CGI Script and Perl First CGI Script and Perl Perl in a nutshell Prof. Rasley shebang line tells the operating system where the Perl interpreter is located necessary on UNIX comment line ignored by the Perl interpreter End

More information

Chapter 14: Boolean Expressions Bradley Kjell (Revised 10/08/08)

Chapter 14: Boolean Expressions Bradley Kjell (Revised 10/08/08) Chapter 14: Boolean Expressions Bradley Kjell (Revised 10/08/08) The if statements of the previous chapters ask simple questions such as count

More information

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C Basic Java Constructs and Data Types Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C 1 Contents Hello World Program Statements Explained Java Program Structure in

More information

Creating a Simple Macro

Creating a Simple Macro 28 Creating a Simple Macro What Is a Macro?, 28-2 Terminology: three types of macros The Structure of a Simple Macro, 28-2 GMACRO and ENDMACRO, Template, Body of the macro Example of a Simple Macro, 28-4

More information

Year 8 KS3 Computer Science Homework Booklet

Year 8 KS3 Computer Science Homework Booklet Year 8 KS3 Computer Science Homework Booklet Information for students and parents: Throughout the year your ICT/Computer Science Teacher will set a number of pieces of homework from this booklet. If you

More information

Java Programming Unit 1. Your first Java Program Eclipse IDE

Java Programming Unit 1. Your first Java Program Eclipse IDE Java Programming Unit 1 Your first Java Program Eclipse IDE During this training course we ll use the textbook Java Programming 24- Hour Trainer by Yakov Fain. Why Learn Java? Large code base of already

More information

SCIENCE PROJECT PAGE 1

SCIENCE PROJECT PAGE 1 SCIENCE PROJECT PAGE 1 Introduction YES!!! It s that Science Fair time of year. No amount of groaning is going to make it go away. Just imagine the inquiry and organizational skills you ll learn and practice.

More information

Example of a Java program

Example of a Java program Example of a Java program class SomeNumbers static int square (int x) return x*x; public static void main (String[] args) int n=20; if (args.length > 0) // change default n = Integer.parseInt(args[0]);

More information

Microsoft Office Word 2007 Training

Microsoft Office Word 2007 Training Microsoft Office Word 2007 Training Created & Hosted by: Hagop (Jack) Hadjinian I.A., Information Technology Course Contents: Lesson 1: Get to know the Ribbon Lesson 2: Find everyday commands The lesson

More information

Android Programming Family Fun Day using AppInventor

Android Programming Family Fun Day using AppInventor Android Programming Family Fun Day using AppInventor Table of Contents A step-by-step guide to making a simple app...2 Getting your app running on the emulator...9 Getting your app onto your phone or tablet...10

More information

DOING MORE WITH WORD: MICROSOFT OFFICE 2010

DOING MORE WITH WORD: MICROSOFT OFFICE 2010 University of North Carolina at Chapel Hill Libraries Carrboro Cybrary Chapel Hill Public Library Durham County Public Library DOING MORE WITH WORD: MICROSOFT OFFICE 2010 GETTING STARTED PAGE 02 Prerequisites

More information

Web App Development Session 1 - Getting Started. Presented by Charles Armour and Ryan Knee for Coder Dojo Pensacola

Web App Development Session 1 - Getting Started. Presented by Charles Armour and Ryan Knee for Coder Dojo Pensacola Web App Development Session 1 - Getting Started Presented by Charles Armour and Ryan Knee for Coder Dojo Pensacola Tools We Use Application Framework - Compiles and Runs Web App Meteor (install from https://www.meteor.com/)

More information

Chapter 1 Introduction to Computers, Programs, and Java

Chapter 1 Introduction to Computers, Programs, and Java Chapter 1 Introduction to Computers, Programs, and Java 1.1 Introduction The central theme of this book is to learn how to solve problems by writing a program. This book teaches you how to create programs

More information

Java Software Development Kit (JDK 5.0 Update 14) Installation Step by Step Instructions

Java Software Development Kit (JDK 5.0 Update 14) Installation Step by Step Instructions Java Software Development Kit (JDK 5.0 Update 14) Installation Step by Step Instructions 1. Click the download link Download the Java Software Development Kit (JDK 5.0 Update 14) from Sun Microsystems

More information

CS 170 Java Programming 1. Welcome to CS 170. All about CS 170 The CS 170 Online Materials Java Mechanics: Your First Program

CS 170 Java Programming 1. Welcome to CS 170. All about CS 170 The CS 170 Online Materials Java Mechanics: Your First Program CS 170 Java Programming 1 Welcome to CS 170 All about CS 170 The CS 170 Online Materials Java Mechanics: Your First Program What s the Plan? Topic I: What s CS 170 All About? Contact information Topics,

More information

3 Improving the Crab more sophisticated programming

3 Improving the Crab more sophisticated programming 3 Improving the Crab more sophisticated programming topics: concepts: random behavior, keyboard control, sound dot notation, random numbers, defining methods, comments In the previous chapter, we looked

More information

Getting Started with 4-part Harmony

Getting Started with 4-part Harmony Getting Started with 4-part Harmony Some of you have already written chord progressions in a previous theory class. However, it is my experience that few students come to college with the ability to consistently

More information

6.1. Example: A Tip Calculator 6-1

6.1. Example: A Tip Calculator 6-1 Chapter 6. Transition to Java Not all programming languages are created equal. Each is designed by its creator to achieve a particular purpose, which can range from highly focused languages designed for

More information

Creating A Simple Dictionary With Definitions

Creating A Simple Dictionary With Definitions Creating A Simple Dictionary With Definitions The KAS Knowledge Acquisition System allows you to create new dictionaries with definitions from scratch or append information to existing dictionaries. The

More information

Appendix K Introduction to Microsoft Visual C++ 6.0

Appendix K Introduction to Microsoft Visual C++ 6.0 Appendix K Introduction to Microsoft Visual C++ 6.0 This appendix serves as a quick reference for performing the following operations using the Microsoft Visual C++ integrated development environment (IDE):

More information

Some Scanner Class Methods

Some Scanner Class Methods Keyboard Input Scanner, Documentation, Style Java 5.0 has reasonable facilities for handling keyboard input. These facilities are provided by the Scanner class in the java.util package. A package is a

More information