Chapter 5: Preparing Java Programs 1 Chapter 5 Preparing Java Programs.

Slides:



Advertisements
Similar presentations
Chapter 1: An Overview of Computers and Programming Languages
Advertisements

How do we make our Welcome.java program do something? The java in our Welcome.java file won’t do anything by itself. We need to tell the computer to execute.
Chapter 1: An Overview of Computers and Programming Languages J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
1 Repetition structures Overview while statement for statement do while statement.
How do we make our HelloTester.java program do something? The java in our HelloTester.java file won’t do anything by itself. We need to tell the computer.
CHAPTER 1 INTRODUCTION GOALS  To understand the activity of programming  To learn about the architecture of computers  To learn about machine code and.
1 LECTURE#7: Console Input Overview l Introduction to Wrapper classes. l Introduction to Exceptions (Java run-time errors). l Console input using the BufferedReader.
Computer Concepts 5th Edition Parsons/Oja Page 546 CHAPTER 11 Software Engineering Section A PARSONS/OJA Computer Programming.
CS211 Data Structures Sami Rollins Fall 2004.
Chapter 16 Programming and Languages: Telling the Computer What to Do.
1 Introduction to Console Input  Primitive Type Wrapper Classes  Converting Strings to Numbers  System.in Stream  Wrapping System.in in a Buffered.
An Introduction to Programming with C++ Fifth Edition Chapter 1 An Introduction to Programming.
CS 101 Problem Solving and Structured Programming in C Sami Rollins Spring 2003.
1. 2 Chapter 1 Introduction to Computers, Programs, and Java.
Types of Computer/Programming Languages Machine Language Symbolic Languages There Are Two Types Of Symbolic Languages Low level Language » Low level language.
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages Updated by: Dr\Ali-Alnajjar.
Programming a computer. What does programming a computer mean ? Programming a computer: Since a computer can only execute machine instructions (encoded.
IB Computer Science II Paul Bui
Shorthand operators.
“Introduction to Programming With Java”
1 Course Lectures Available on line:
Basics Programming Concepts. Basics A computer program is a set of instructions to tell a computer what to do Machine language = circuit level language.
Chapter 1.4 Programming languages Homework Due: Monday, August 11, 2014.
CSCI 115 Computer Programming Overview. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software.
Programming Language Rico Yu. Levels of Programming Languages 1.Low level languages 2.High level languages.
Introduction to Computers and Java Chapter 1.3. A Sip of Java: Outline History of the Java Language Applets A First Java Program Compiling a Java Program.
CSI 1390: Introduction to Computers TA: Tapu Kumar Ghose Office: STE 5014
Console Input. So far… All the inputs for our programs have been hard-coded in the main method or inputted using the dialog boxes of BlueJ It’s time to.
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Programming Concept Chapter I Introduction to Java Programming.
Java means Coffee Java Coffee Beans The name “JAVA” was taken from a cup of coffee.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
JAVA PROGRAMMING BASICS CHAPTER 2. History of Java Begin with project Green in 1991 founded by Patrick Noughton, Mike Sheridan and James Gosling who worked.
Working with arrays (we will use an array of double as example)
Programming Fundamentals 2: Simple/ F II Objectives – –give some simple examples of Java applications and one applet 2. Simple Java.
Mixing integer and floating point numbers in an arithmetic operation.
J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition Second Edition D.S. Malik D.S. Malik.
1 3. Computing System Fundamentals 3.1 Language Translators.
Overview of Java CSCI 392 Day One. Running C code vs Java code C Source Code C Compiler Object File (machine code) Library Files Linker Executable File.
Using the while-statement to process data files. General procedure to access a data file General procedure in computer programming to read data from a.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
The assignment expressions. The assignment operator in an assignment statement We have seen the assignment statement: Effect: var = expr; Stores the value.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
Java FilesOops - Mistake Java lingoSyntax
CHAPTER 1 INTRODUCTION. CHAPTER GOALS To understand the activity of programming To learn about the architecture of computers To learn about machine code.
Exceptions. Exception  Abnormal event occurring during program execution  Examples Manipulate nonexistent files FileReader in = new FileReader("mumbers.txt“);
Introduction to array: why use arrays ?. Motivational example Problem: Write a program that reads in and stores away 5 double numbers After reading in.
CSCI 115 Computer Programming Overview. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software.
Software Engineering Algorithms, Compilers, & Lifecycle.
Chapter 5: Preparing C Programs
Why don’t programmers have to program in machine code?
Introduction to Computers and C++ Programming
Chapter 1: An Overview of Computers and Programming Languages
Compiling and Running a Java Program
Chapter 1: An Overview of Computers and Programming Languages
CS1101: Programming Methodology Recitation 7 – Exceptions
TRANSLATORS AND IDEs Key Revision Points.
Chapter 1: An Overview of Computers and Programming Languages
L3. Necessary Java Programming Techniques
L3. Necessary Java Programming Techniques
Chapter 1: An Overview of Computers and Programming Languages
An Introduction to Programming with C++ Fifth Edition
IB Computer Science II Paul Bui
Developing Java Applications with NetBeans
F II 2. Simple Java Programs Objectives
Presentation transcript:

Chapter 5: Preparing Java Programs 1 Chapter 5 Preparing Java Programs

Chapter 5Program development2 EDIT Understanding the problem Writing an algorithm Converting to code COMPILE RUN errors Result Verifying the algorithm

Chapter 5Program development3 EDIT COMPILE RUN errors Result Source code pico prog.java javac prog.java java prog

Chapter 5High-level languages4 qMachine language: computer’s native language. Add two numbers: qAssembly language: uses mnemonics. Add two numbers: ADD R1 R2 An assembly code needs to be translated to machine code.

Chapter 5High-level languages5 qHigh-level programming languages: bridging the gap between machine language and natural languages. qExamples: COBOL, Fortran, Algol, C Add two numbers (in C): Z = A + B; qCompilation: translation to machine code.

Chapter 5A Java program6 qA sample Java program // A Java program to read a number and compute and display its square. import java.io.*; class square { public static void main(String arg[]) throws IOException { int n; BufferedReader stdin = new BufferedReader (new InputStreamReader (System.in)); System.out.print ("Enter the number to be square: "); n = Integer.parseInt (stdin.readLine()); System.out.println ("The square of " + n + " is " + n*n); }

Chapter 5Compilation in Java7 qUse the javac command to compile: javac prog.java qProduces the object file with extension.class (eg: prog.class) qTo run object file, use the java command: java prog

Chapter 5Errors8 qCompilation errors: occur during compilation. uReason: syntax errors. uEasy to rectify. qRun-time errors: occur during execution. uReasons: logic errors, data errors, computation errors. uHarder to rectify.

Chapter 5Homework9