CS-201 Introduction to Programming with Java

Save this PDF as:
 WORD  PNG  TXT  JPG

Size: px
Start display at page:

Download "CS-201 Introduction to Programming with Java"

Transcription

1 CS-201 Introduction to Programming with Java California State University, Los Angeles Computer Science Department Lecture I: Introduction to Computers, Programs, and Java

2 Basic Computer Architecture: Binary Data Representation and Memory

3 Memory An ordered sequence of bytes for storing programs and the data that the program is working with. bytes of memory can be access randomly (RAM Random-Access Memory) programs and data moved into memory before execution by CPU Every byte in the memory has a unique address memory is volatile: Data is lost when the power is lost (reboot, shutdown, or other power interruptions)

4 Memory

5 Bits and Bytes Computers are just a series of switches. switches can be on or off on = 1, off = 0 0s and 1s are interpreted as digits in the binary number system and are called bits. By using the different combinations of on and off switches (bit configurations) in a byte, any letter, character, or number on the keyboard can be represented in binary. Do you know which number is represented by the switches in this picture?

6 Bits and Bytes byte: the minimum storage unit of a computer. memory is organized according to bytes 8 bits = 1 byte 16 bits = 2 bytes = 1 word 32 bits = 4 bytes = 2 words = 1 dword (double word)

7 Bits and Bytes Storage capacity is measured as follows: kilobytes (KB) = 1,000 bytes megabytes (MB) = 1 million bytes gigabytes (GB) = 1 billion bytes terabytes (TB) = 1 trillion bytes

8 Binary to Decimal Conversion Every computer scientist should know how to convert between the Binary number system and the Decimal (Base 10) Number system. Each digit of a binary number represents a power of 2 starting from the right at 20 To find the Decimal representation, simply add up the powers of two where ever there is a 1 in the binary number Example: = = 216

9 Decimal to Binary Conversion To convert from Decimal to Binary divide the original value by 2 keep track of the quotient and the remainder. Continue to divide each new quotient by 2 until the quotient is 0. Keep track of the remainders each time. The binary number will be the remainders going backwards NOTE: If you have less than 8 remainders pad the left side of the binary number with 0s until the number of binary digits is 8.

10 Decimal to Binary Conversion The binary number will be the remainders in reverse. 216 = **Remember to add (pad) 0s to the left if necessary.

11 Software and Programming Languages

12 Software (Programs) Instructions to the computer that tell the computer exactly what to do. Without programs a computer is just a large paperweight! Software is written in computer languages computers don't understand human languages.

13 Programming Languages A language a computer can understand. makes writing programs easier programming in pure machine code is tedious Languages come in three general categories: Machine Languages Assembly Languages High-Level Languages

14 Machine Language (Machine Code) Built-in primitive instructions in the form of binary code. Instructions are unique to the hardware configuration The native language of computers. the instruction that works on one may not work on another computer. Instructions are in binary: Example: To add two numbers you might have a piece of binary code which looks like:

15 High-Level Languages First developed in the 1950s. Platform-independent, you can write a program in a high-level language on one computer and run it on different types of machines. English-like, easier to learn and use. Instructions in a high-level programming language are called statements. Example, Compute the area of a circle with radius of 5: area = 5 * 5 *

16 Popular High Level Languages

17 Translate High-Level Language to Machine Language A high-level language program is called a source program or source code. Source programs are not directly understood by computers. source code must be translated into machine code.

18 Translate High-Level Language to Machine Language Translation is done using one (or both) of the following techniques: interpreting: performed by software called an interpreter reads one statement at a time from the source code at a time, translates it into machine code then executes it right away. compiling: performed by software called a compiler. translates the entire source code into a machine-code file. the machine-code file is then executed. NOTE: Some languages use a combination of compiling and interpreting (Java and Python are examples).

19 First Java Program

20 The Task Display the following message on the screen: *** hello, world! *** *** Welcome to CS 201! *** Why hello, world? Common first time programming example for beginning programmers See the article about Hello, World under the reading assignments for this week.

21 Writing and Editing a Java Program It doesn't take anything fancy to write a simple program. You can use something a mundane as a text editor: Notepad Notepad++ (Recommended for Windows Users) Some Mac Equivalent Text Editor NetBeans or Eclipse IDE (We will be using this after the midterm) As long as you have the JDK (Java Development Kit) installed, you can compile and run (execute) Java programs using the Windows Command Line or the Mac Terminal. (More on this later) All source code files (the files you will be writing) should be saved with the.java file extension. Don't save the file as.txt by accident or else your program will not work correctly.

22 The Source Code of Our Program /* Author: Keenan Knaur Purpose: Display a welcome message to the console. */ public class Hello { // method main(): application entry point public static void main(string[] args) { System.out.println("*** Hello, everybody! ***"); System.out.println("*** Welcome to CS 201!***"); } }

23 Comments /* Author: Keenan Knaur Purpose: Display a welcome message to the console. */ public class Hello { // method main(): application entry point public static void main(string[] args) { System.out.println("*** Hello, everybody! ***"); System.out.println("*** Welcome to CS 201!***"); } } Comments

24 Comments Notes put into the source code by the programmer. Document what the program does and how sections of the program work. Ignored by the Java compiler Three types of comments: Single Line comments: preceded by two slashes (//) Paragraph comments: A paragraph comment is enclosed between /* and */ over one or multiple lines Javadoc comments: Multi-line comment between /** and */. They are used for documenting classes, data, and methods. They can be exported to an HTML file.

25 Classes /* Author: Keenan Knaur Purpose: Display a welcome message to the console. */ Class Header public class Hello { // method main(): application entry point public static void main(string[] args) { System.out.println("*** Hello, everybody! ***"); System.out.println("*** Welcome to CS 201!***"); } } Class

26 Classes Generally there is one class per.java file and every program needs at least one class. Class Header (declaration) public (an access modifier, will learn more about these later) class keyword used to identify where the class begins classname User specified all classes must have a name must be the same as the file name Class Body Enclosed in a pair of { }

27 Naming Rules for Classes Rules Must start with a letter Cannot conflict with any language keywords or symbols Case-sensitive Conventions Class names start with an upper-case letter Multiple words are concatenated and each subsequent word has its first letter in upper-case. The class name has to match exactly the name of the java file that contains the class Example: if I have a class called WelcomeToJava then it should be saved in a file called WelcomeToJava.java

28 Methods /* Author: Keenan Knaur Purpose: Display a welcome message to the console. */ Method Header public class Hello { // method main(): application entry point public static void main(string[] args) { System.out.println("*** Hello, everybody! ***"); System.out.println("*** Welcome to CS 201!***"); } } Method

29 Methods Each class can contain one or more methods A method is a named piece of code that performs some action Method header (declaration) public access modifier static void (the return type of the method) Method name User specified Arguments enclosed in a pair of ( ) Method body Enclosed in a pair of { }

30 The main() Method main() is a special method in Java Every program MUST have a main method inside one of its classes in order for the program to execute. Programs can only have ONE main method The header of the main method always looks like: public static void main(string[] args) { }

31 Statements /* Author: Keenan Knaur Purpose: Display a welcome message to the console. */ public class Hello { // method main(): application entry point public static void main(string[] args) { System.out.println("*** Hello, everybody! ***"); System.out.println("*** Welcome to CS 201!***"); } } Statements

32 Statements Statements are the sentences in a programming language. They are an action or sequence of actions. Methods can contain many many statements. Ends in a semicolon (;) called the statement terminator May consist of other statements

33 Printing to the Console

34 Reserved Words (Keywords) /* Author: Keenan Knaur Purpose: Display a welcome message to the console. */ public class Hello { // method main(): application entry point public static void main(string[] args) { System.out.println("*** Hello, everybody! ***"); System.out.println("*** Welcome to CS 201!***"); } } Reserved Words

35 Reserved Words (Keywords) Reserved words or keywords are words that have a specific meaning to the compiler and cannot be used for any other purpose in the program. For example, when the compiler sees the word class, it understands that the word after class is the name for the class. Also note that Java source programs are case sensitive, so it would be wrong to write Main instead of main.

36 Blocks of Code /* Author: Keenan Knaur Purpose: Display a welcome message to the console. */ public class Hello { // method main(): application entry point public static void main(string[] args) { System.out.println("*** Hello, everybody! ***"); System.out.println("*** Welcome to CS 201!***"); } Main } Block Class Block

37 Blocks of Code A pair of curly braces in a program forms a block that groups together components of a program. Every class has a class block that groups the data and methods of the class. Every method has a method block that groups the statements in a method. Blocks can be nested i.e. one block can be placed within another. All opening braces MUST have a matching closing brace. When you type an opening brace immediately press the enter key a few times then type the closing brace to prevent a missing-brace error.

38 Brace Style next-line style: aligns braces vertically making programs easy to read end-of-line style: saves space may avoid some subtle programming errors both styles are acceptable, but once you pick a style you should be consistent. I prefer end-of-line style because it looks nicer

39 Proper Spacing and Indentation Good indentation makes a program easier to read, debug, and maintain. Proper spacing between statement components should be used to also make reading the program easier System.out.println(3+4*4); is ok System.out.println(3 + 4 * 4); is better

40 Why the JVM (Java Virtual Machine)? The Java Virtual Machine is what makes Java programs platform-independent Write Once, Run Anywhere: easy to run the same Java code in UNIX/OSX/Windows/ etc. reduces the amount of knowledge the programmer needs to have about the specific platform. adds long-term robustness. Your Java code will still run in Windows 18.7 as long as there is a JVM that can run it.

41 Translating Java to Machine Code Java uses both an interpreter and a compiler. The Java source code is compiled before runtime into an intermediate language called Java bytecode. The Java Virtual Machine interprets bytecode to machine language at runtime. Each platform (operating system or hardware type) requires a different type of JVM, but all forms of the JVM run the same bytecode.

42 Translating Java to Machine Code

43 Translating Java to Machine Code

44 Introduction to Command Line Compiling

45 Where to Save Your Programs To make things incredibly easy for you, save all of your programs for this class in a folder at the root of your C: drive or the root of your USB flash drive. This will make navigating to your files through the terminal much much easier.

46 Opening a Terminal / Console Window Varies between different versions of windows. Demonstrate in class.

47 Directories In DOS, folders are known as directories directories hold files you can create or delete them at will All directories are organized in a hierarchical way The topmost directory is called the root directory c:\> The root directory contains many sub-directories Each sub-directory may contain many sub-sub-directories

48 Viewing the Contents of a Directory To view the contents of the current directory that you are in, use the dir command

49 Changing Directories to change directories used the cd command change to a sub-directory of the current directory Command: cd sub-directory-name Example: Change to the parent directory cd myjava Command: cd.. Change to the root directory from any directory Command: cd \

50 Changing Directories

51 Further Reading For more on DOS commands see the supplementary material on the course website.

52 Compiling Your First Java Program Navigate to the directory (folder) where your java files are located. For Example: lets say your directory structure looked something like this: c:> my_programs MyProgram.java navigate into my_programs cd my_programs once in the folder use the javac command to compile your program javac MyProgram.java notice that the extension must be part of the file name when you are using the javac command After you compile the program you will either see some errors, or the compiler will generate a.class file with the same name as your program i.e. myprogram.class. To run your program use the java command java MyProgram notice that you DO NOT add the file extension when running your program.

53 Programming Errors "It's hard enough to find an error in your code when you're looking for it; it's even harder when you've assumed your code is error-free." ~Steve McConnell

54 Syntax Errors (Compile Errors) Errors detected by the compiler which result from incorrect code construction. Prevent the compiler from properly compiling the program and the program will not execute. Examples include: mistyping a keyword, omitting some necessary punctuation, missing matching braces, etc.

55 Run-time Errors Errors that cause a program to terminate abnormally. The compiler is able to compile and execute the program, but during execution the program will stop unexpectedly if the JVM detects an operation that is impossible to carry out. Examples include input mistakes, or division by zero

56 Logic Errors Errors that occur when a program does not perform the way it was intended to. Can be hard to detect because the fault lies in the user s logic (thought processes) behind the program. For example: Suppose you write a program to calculate the area of a circle and instead of using the formula 2 * π * r you mistakenly use 3 * π * r. This would cause a logic error because the program will execute and finish and the compiler will give no errors but the logic behind the formula is faulty which results in the incorrect output.

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

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

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

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

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

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

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

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 Goals. 1.1 Computer Programs. Contents 1/9/13

Chapter Goals. 1.1 Computer Programs. Contents 1/9/13 CHAPTER 1 Chapter Goals To learn about computers and programming To compile and run your first Java program To recognize compile-time and run-time errors To describe an algorithm with pseudocode In this

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

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 Java is the Internet program language Why Java? The answer is that Java enables user to deploy applications on the Internet for

More information

CS 16: Assembly Language Programming for the IBM PC and Compatibles

CS 16: Assembly Language Programming for the IBM PC and Compatibles CS 16: Assembly Language Programming for the IBM PC and Compatibles First, a little about you Your name Have you ever worked with/used/played with assembly language? If so, talk about it Why are you taking

More information

The COMPSCI 101 Text Editor for Windows. The text editor that we will be using in the Computer Science

The COMPSCI 101 Text Editor for Windows. The text editor that we will be using in the Computer Science Notepad++ The COMPSCI 101 Text Editor for Windows The text editor that we will be using in the Computer Science labs for creating our Java programs is called Notepad++ and is http://notepad- plus.sourceforge.net

More information

Activity 1: Bits and Bytes

Activity 1: Bits and Bytes ICS3U (Java): Introduction to Computer Science, Grade 11, University Preparation Activity 1: Bits and Bytes The Binary Number System Computers use electrical circuits that include many transistors and

More information

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq Introduction to Programming using Java wertyuiopasdfghjklzxcvbnmqwertyui

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

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

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

C Programming Dr. Hasan Demirel

C Programming Dr. Hasan Demirel C How to Program, H. M. Deitel and P. J. Deitel, Prentice Hall, 5 th edition (3 rd edition or above is also OK). Introduction to C Programming Dr. Hasan Demirel Programming Languages There are three types

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

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

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. Exam Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) The JDK command to compile a class in the file Test.java is A) java Test.java B) java

More information

Chapter 1 Fundamentals of Java Programming

Chapter 1 Fundamentals of Java Programming Chapter 1 Fundamentals of Java Programming Computers and Computer Programming Writing and Executing a Java Program Elements of a Java Program Features of Java Accessing the Classes and Class Members The

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

Eclipse installation, configuration and operation

Eclipse installation, configuration and operation Eclipse installation, configuration and operation This document aims to walk through the procedures to setup eclipse on different platforms for java programming and to load in the course libraries for

More information

An Introduction to the Java Programming Language History of Java

An Introduction to the Java Programming Language History of Java An Introduction to the Java Programming Language History of Java In 1991, a group of Sun Microsystems engineers led by James Gosling decided to develop a language for consumer devices (cable boxes, etc.).

More information

Lecture 03 Bits, Bytes and Data Types

Lecture 03 Bits, Bytes and Data Types Lecture 03 Bits, Bytes and Data Types In this lecture Computer Languages Assembly Language The compiler Operating system Data and program instructions Bits, Bytes and Data Types ASCII table Data Types

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

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

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

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T) Unit- I Introduction to c Language: C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating

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

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

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

Outline. hardware components programming environments. installing Python executing Python code. decimal and binary notations running Sage

Outline. hardware components programming environments. installing Python executing Python code. decimal and binary notations running Sage Outline 1 Computer Architecture hardware components programming environments 2 Getting Started with Python installing Python executing Python code 3 Number Systems decimal and binary notations running

More information

Bits and Bytes. Computer Literacy Lecture 4 29/09/2008

Bits and Bytes. Computer Literacy Lecture 4 29/09/2008 Bits and Bytes Computer Literacy Lecture 4 29/09/2008 Lecture Overview Lecture Topics How computers encode information How to quantify information and memory How to represent and communicate binary data

More information

Opening a Command Shell

Opening a Command Shell Opening a Command Shell Win Cmd Line 1 In WinXP, go to the Programs Menu, select Accessories and then Command Prompt. In Win7, go to the All Programs, select Accessories and then Command Prompt. Note you

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

Programming Fundamental. Instructor Name: Lecture-2

Programming Fundamental. Instructor Name: Lecture-2 Programming Fundamental Instructor Name: Lecture-2 Today s Lecture What is Programming? First C++ Program Programming Errors Variables in C++ Primitive Data Types in C++ Operators in C++ Operators Precedence

More information

Java with Eclipse: Setup & Getting Started

Java with Eclipse: Setup & Getting Started Java with Eclipse: Setup & Getting Started Originals of slides and source code for examples: http://courses.coreservlets.com/course-materials/java.html Also see Java 8 tutorial: http://www.coreservlets.com/java-8-tutorial/

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

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection

More information

Pemrograman Dasar. Basic Elements Of Java

Pemrograman Dasar. Basic Elements Of Java Pemrograman Dasar Basic Elements Of Java Compiling and Running a Java Application 2 Portable Java Application 3 Java Platform Platform: hardware or software environment in which a program runs. Oracle

More information

Lab Experience 17. Programming Language Translation

Lab Experience 17. Programming Language Translation Lab Experience 17 Programming Language Translation Objectives Gain insight into the translation process for converting one virtual machine to another See the process by which an assembler translates assembly

More information

Introduction to Python

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

More information

IN THIS CHAPTER,YOU ARE INTRODUCED to the C language so that you can see what

IN THIS CHAPTER,YOU ARE INTRODUCED to the C language so that you can see what 3 Compiling and Running Your First Program IN THIS CHAPTER,YOU ARE INTRODUCED to the C language so that you can see what programming in C is all about.what better way to gain an appreciation for this language

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

The Basics of C Programming. Marshall Brain

The Basics of C Programming. Marshall Brain The Basics of C Programming Marshall Brain Last updated: October 30, 2013 Contents 1 C programming 1 What is C?................................. 2 The simplest C program, I........................ 2 Spacing

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

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

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

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

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

C# and Other Languages

C# and Other Languages C# and Other Languages Rob Miles Department of Computer Science Why do we have lots of Programming Languages? Different developer audiences Different application areas/target platforms Graphics, AI, List

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

CSC230 Getting Starting in C. Tyler Bletsch

CSC230 Getting Starting in C. Tyler Bletsch CSC230 Getting Starting in C Tyler Bletsch What is C? The language of UNIX Procedural language (no classes) Low-level access to memory Easy to map to machine language Not much run-time stuff needed Surprisingly

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

Outline: Operating Systems

Outline: Operating Systems Outline: Operating Systems What is an OS OS Functions Multitasking Virtual Memory File Systems Window systems PC Operating System Wars: Windows vs. Linux 1 Operating System provides a way to boot (start)

More information

Memory is implemented as an array of electronic switches

Memory is implemented as an array of electronic switches Memory Structure Memory is implemented as an array of electronic switches Each switch can be in one of two states 0 or 1, on or off, true or false, purple or gold, sitting or standing BInary digits (bits)

More information

Access Tutorial 12: An Introduction to Visual Basic

Access Tutorial 12: An Introduction to Visual Basic Access Tutorial 12: An Introduction to Visual Basic 12.1 Introduction: Learning the basics of programming Programming can be an enormously complex and difficult activity. Or it can be quite straightforward.

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

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

Java Programming Fundamentals

Java Programming Fundamentals Lecture 1 Part I Java Programming Fundamentals Topics in Quantitative Finance: Numerical Solutions of Partial Differential Equations Instructor: Iraj Kani Introduction to Java We start by making a few

More information

Programming Languages

Programming Languages Programming Languages In the beginning To use a computer, you needed to know how to program it. Today People no longer need to know how to program in order to use the computer. To see how this was accomplished,

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

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

TN203. Porting a Program to Dynamic C. Introduction

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

More information

CS101 Lecture 24: Thinking in Python: Input and Output Variables and Arithmetic. Aaron Stevens 28 March 2011. Overview/Questions

CS101 Lecture 24: Thinking in Python: Input and Output Variables and Arithmetic. Aaron Stevens 28 March 2011. Overview/Questions CS101 Lecture 24: Thinking in Python: Input and Output Variables and Arithmetic Aaron Stevens 28 March 2011 1 Overview/Questions Review: Programmability Why learn programming? What is a programming language?

More information

Chapter 2: Elements of Java

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

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

Java How to Program, 9/e

Java How to Program, 9/e Java How to Program, 9/e Education, Inc. All Rights Reserved. 1 Any computing problem can be solved by executing a series of actions in a specific order. An algorithm is a procedure for solving a problem

More information

ICS Technology. PADS Viewer Manual. ICS Technology Inc PO Box 4063 Middletown, NJ 077748 732-671-5400 www.icstec.com

ICS Technology. PADS Viewer Manual. ICS Technology Inc PO Box 4063 Middletown, NJ 077748 732-671-5400 www.icstec.com ICS Technology PADS Viewer Manual ICS Technology Inc PO Box 4063 Middletown, NJ 077748 732-671-5400 www.icstec.com Welcome to PADS Viewer Page 1 of 1 Welcome to PADS Viewer Welcome to PADS (Public Area

More information

Data Representation. Data Representation, Storage, and Retrieval. Data Representation. Data Representation. Data Representation. Data Representation

Data Representation. Data Representation, Storage, and Retrieval. Data Representation. Data Representation. Data Representation. Data Representation , Storage, and Retrieval ULM/HHIM Summer Program Project 3, Day 3, Part 3 Digital computers convert the data they process into a digital value. Text Audio Images/Graphics Video Digitizing 00000000... 6/8/20

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

3 SOFTWARE AND PROGRAMMING LANGUAGES

3 SOFTWARE AND PROGRAMMING LANGUAGES 3 SOFTWARE AND PROGRAMMING LANGUAGES 3.1 INTRODUCTION In the previous lesson we discussed about the different parts and configurations of computer. It has been mentioned that programs or instructions have

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

Student Workbook for Murach s Java SE 6

Student Workbook for Murach s Java SE 6 Student Workbook for Murach s Java SE 6 Introduction for students... ii Chapter 1...1 Chapter 2...6 Chapter 3...14 Chapter 4...22 Chapter 5...29 Chapter 6...38 Chapter 7...47 Chapter 8...56 Chapter 9...65

More information

PMOD Installation on Linux Systems

PMOD Installation on Linux Systems User's Guide PMOD Installation on Linux Systems Version 3.7 PMOD Technologies Linux Installation The installation for all types of PMOD systems starts with the software extraction from the installation

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

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

Computers. Hardware. The Central Processing Unit (CPU) CMPT 125: Lecture 1: Understanding the Computer

Computers. Hardware. The Central Processing Unit (CPU) CMPT 125: Lecture 1: Understanding the Computer Computers CMPT 125: Lecture 1: Understanding the Computer Tamara Smyth, tamaras@cs.sfu.ca School of Computing Science, Simon Fraser University January 3, 2009 A computer performs 2 basic functions: 1.

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

Chapter 13: Program Development and Programming Languages

Chapter 13: Program Development and Programming Languages Understanding Computers Today and Tomorrow 12 th Edition Chapter 13: Program Development and Programming Languages Learning Objectives Understand the differences between structured programming, object-oriented

More information

AQA GCSE in Computer Science Computer Science Microsoft IT Academy Mapping

AQA GCSE in Computer Science Computer Science Microsoft IT Academy Mapping AQA GCSE in Computer Science Computer Science Microsoft IT Academy Mapping 3.1.1 Constants, variables and data types Understand what is mean by terms data and information Be able to describe the difference

More information

The programming language C. sws1 1

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

More information

Computer Science 217

Computer Science 217 Computer Science 217 Midterm Exam Fall 2009 October 29, 2009 Name: ID: Instructions: Neatly print your name and ID number in the spaces provided above. Pick the best answer for each multiple choice question.

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

C Programming. for Embedded Microcontrollers. Warwick A. Smith. Postbus 11. Elektor International Media BV. 6114ZG Susteren The Netherlands

C Programming. for Embedded Microcontrollers. Warwick A. Smith. Postbus 11. Elektor International Media BV. 6114ZG Susteren The Netherlands C Programming for Embedded Microcontrollers Warwick A. Smith Elektor International Media BV Postbus 11 6114ZG Susteren The Netherlands 3 the Table of Contents Introduction 11 Target Audience 11 What is

More information

Automatic Threshold Values and Variables

Automatic Threshold Values and Variables Automatic Threshold Values and Variables In this lesson, we re going to look a little deeper into the world of values, and pay special attention to the programming structures that are used to represent

More information

Introduction to Eclipse

Introduction to Eclipse Introduction to Eclipse Overview Eclipse Background Obtaining and Installing Eclipse Creating a Workspaces / Projects Creating Classes Compiling and Running Code Debugging Code Sampling of Features Summary

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

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

Introduction to Programming

Introduction to Programming Introduction to Programming If you re new to programming, you might be intimidated by code and flowcharts. You might even wonder how you ll ever understand them. This lesson offers some basic ideas and

More information

Java Interview Questions and Answers

Java Interview Questions and Answers 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write and compile the java

More information

JAVA - PACKAGES. java.io - classes for input, output functions are bundled in this package

JAVA - PACKAGES. java.io - classes for input, output functions are bundled in this package http://www.tutorialspoint.com/java/java_packages.htm JAVA - PACKAGES Copyright tutorialspoint.com Packages are used in Java in order to prevent naming conflicts, to control access, to make searching/locating

More information

JavaScript: Introduction to Scripting. 2008 Pearson Education, Inc. All rights reserved.

JavaScript: Introduction to Scripting. 2008 Pearson Education, Inc. All rights reserved. 1 6 JavaScript: Introduction to Scripting 2 Comment is free, but facts are sacred. C. P. Scott The creditor hath a better memory than the debtor. James Howell When faced with a decision, I always ask,

More information

Objectives. Python Programming: An Introduction to Computer Science. Lab 01. What we ll learn in this class

Objectives. Python Programming: An Introduction to Computer Science. Lab 01. What we ll learn in this class Python Programming: An Introduction to Computer Science Chapter 1 Computers and Programs Objectives Introduction to the class Why we program and what that means Introduction to the Python programming language

More information

C Syntax and Semantics

C Syntax and Semantics C Syntax and Semantics 1 C Program Structure C Language Elements Preprocessor directives Function Header, and Function body Executable statements Reserved word, Standard identifiers, user defined identifiers

More information

CS3600 SYSTEMS AND NETWORKS

CS3600 SYSTEMS AND NETWORKS CS3600 SYSTEMS AND NETWORKS NORTHEASTERN UNIVERSITY Lecture 2: Operating System Structures Prof. Alan Mislove (amislove@ccs.neu.edu) Operating System Services Operating systems provide an environment for

More information

Crash Course in Java

Crash Course in Java Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J. Johns also: Java in a Nutshell Java Network Programming and Distributed Computing Netprog 2002 Java Intro 1 What is

More information