Prepared by Uzma Hashmi Instructor Information Uzma Hashmi Office: B# 7/ R#1-121 address: Group Addresses Post message:

Slides:



Advertisements
Similar presentations
Chapter 1: Computer Systems
Advertisements

Programming Languages
Programming with Java. Problem Solving The purpose of writing a program is to solve a problem The general steps in problem solving are: –Understand the.
Dale Roberts Introduction to Java - First Program Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.
IntroductionIntroduction  Computer program: an ordered sequence of statements whose objective is to accomplish a task.  Programming: process of planning.
1 Kursusform  13 uger med: Undervisning i klassen 1,5-2 timer Opgave ”regning” i databar (løsninger på hjemmeside) En midtvejsopgave der afleveres og.
The Java Programming Language
Outline Java program structure Basic program elements
Chapter 1 Introduction. © 2004 Pearson Addison-Wesley. All rights reserved1-2 Outline Computer Processing Hardware Components Networks The Java Programming.
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
Chapter 1 Introduction.
Copyright 2013 by Pearson Education Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Java Software Solutions Lewis and Loftus Chapter 2 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Software Concepts -- Introduction.
Java: Chapter 1 Computer Systems Computer Programming II Aug
Chapter 1 Introduction.
Chapter 1 Programming Languages. Application Development: Top 10 Programming Languages to Keep You Employed 1. Java 2. C# 3. C++ 4. JavaScript 5. Visual.
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley John Lewis, Peter DePasquale, and Joseph Chase Chapter 1: Introduction.
© 2006 Pearson Education Computer Systems Presentation slides for Java Software Solutions for AP* Computer Science A 2nd Edition.
Java: Chapter 1 Computer Systems Computer Programming II.
Java Language and SW Dev’t
© 2006 Pearson Education 1 Obj: cont 1.3 and 1.4, to become familiar with identifiers and to understand how programming languages work HW: p.51 #1.8 –
1 Computer Systems -- Introduction  Chapter 1 focuses on:  the structure of a Java application  basic program elements  preparing and executing a program.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
The Java Programming Language
CSC204 – Programming I Lecture 4 August 28, 2002.
Introduction. Objectives An overview of object-oriented concepts. Programming and programming languages An introduction to Java 1-2.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
Chapter 2: Java Fundamentals
Chapter 1: Introduction Java Programming Language How the Java Virtual Machine Works (compiling, etc…) Update by: Dan Fleck Coming up: The Java Programming.
Java The Java programming language was created by Sun Microsystems, Inc. It was introduced in 1995 and it's popularity has grown quickly since A programming.
SE-1010 Dr. Mark L. Hornick 1 Variables & Datatypes.
Instructor: Alexander Stoytchev CprE 185: Intro to Problem Solving (using C)
Lecture 2 Software Concepts Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
1 Problem Solving b The purpose of writing a program is to solve a problem b The general steps in problem solving are: Understand the problemUnderstand.
White Space Spaces, blank lines, and tabs are collectively called white space and are used to separate words and symbols in a program Extra white space.
Java Language Basics By Keywords Keywords of Java are given below – abstract continue for new switch assert *** default goto * package.
Intro to Programming  Chapter 1 Part 2  Problem Solving.
Java Software Solutions Lewis and Loftus Chapter 2 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Software Concepts -- Introduction.
Java.
Chapter 1 Introduction. 2 Focus of the Course Object-Oriented Software Development problem solving program design, implementation, and testing object-oriented.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
© 2011 Pearson Education, publishing as Addison-Wesley Chapter 1: Computer Systems Presentation slides for Java Software Solutions for AP* Computer Science.
Introduction to Java Programming by Laurie Murphy Revised 09/08/2016.
Copyright 2010 by Pearson Education APCS Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
1 Problem Solving  The purpose of writing a program is to solve a problem  The general steps in problem solving are: Understand the problem Dissect the.
JAVA MULTIPLE CHOICE QUESTION.
Working with Java.
University of Central Florida COP 3330 Object Oriented Programming
1.3 Problem Solving The purpose of writing a program is to solve a problem The general steps in problem solving are: Understand the problem Dissect the.
null, true, and false are also reserved.
Introduction to Java Programming
An overview of Java, Data types and variables
Instructor: Alexander Stoytchev
Chapter 1: Computer Systems
Units with – James tedder
Units with – James tedder
JavaScript Reserved Words
Instructor: Alexander Stoytchev
Java Software Solutions Foundations of Program Design 9th Edition
Focus of the Course Object-Oriented Software Development
Module 2 - Part 1 Variables, Assignment, and Data Types
CSE 142, Spring 2012 Building Java Programs Chapter 1
Instructor: Alexander Stoytchev
Chap 2. Identifiers, Keywords, and Types
Agenda Types and identifiers Practice Assignment Keywords in Java
Zorah Fung University of Washington, Winter 2016
Presentation transcript:

Prepared by Uzma Hashmi Instructor Information Uzma Hashmi Office: B# 7/ R# address: Group Addresses Post message: Subscribe:  I will use this group to communicate and all the Slides will be posted on the group after each lesson CPCS-202 LAB -1

Prepared by Uzma Hashmi Learning Outcomes of Lab-1 1.Installation of jdk1.7 and IDE ECLIPSE 2.Understanding the IDE 3.Writing,Running and Debugging the code 4.Studying the structure of a Java Program 5.Adding Comments 6.White Spaces 7.Identifiers

Prepared by Uzma Hashmi In this semester we will learn JAVA The IDE (integrated development environment)we will use will be Eclipse The compiler is jdk(java development kit) Now we will see how can we install both in Part A and Part B See next slides for the installation steps

Prepared by Uzma Hashmi First you need to install jdk for java language compilation To do so we'll access this web link /downloads/index.html

Prepared by Uzma Hashmi Step 1: index.html JRE (Java Runtime Environment) on your system to run Java applications and applets. To develop Java applications and applets, you need the JDK (Java Development Kit), which includes the JRE

Prepared by Uzma Hashmi Quick Tip Click Start, then click on Run or Start Search. Type msinfo32.exe and then press Enter key. In “System Information”, review the value for the System Type item: For 32-bit editions of Windows, the value of the System Type item is x86-based PC.System Type For 64-bit editions of Windows, the value of the System Type item is x64-based PC.

Prepared by Uzma Hashmi 7

Prepared by Uzma Hashmi Extract the files and there you get the files listed below

Prepared by Uzma Hashmi Using Eclipse The system will prompt you for a workspace. The workspace is the place there you store your Java projects (more on workspaces later). Select a suitable (empty) directory and press Ok.

Prepared by Uzma Hashmi Click here

Prepared by Uzma Hashmi Creating Java Project Select from the menu File -> New-> Java project.

Prepared by Uzma Hashmi

Creating Packages inside the work-space

Prepared by Uzma Hashmi

Another way of Running your code RunDebug

Prepared by Uzma Hashmi Use of Refactor Once you have created your file,you can change the name of the file using the refactor option

Prepared by Uzma Hashmi

Error description in Problems

Prepared by Uzma Hashmi

Structure of the program In the Java programming language: – A program is made up of one or more classes – A class contains one or more methods – A method contains program statements These terms will be explored in detail throughout the course A Java application always contains a method called main, A Java application name must be the same as the class name.

Prepared by Uzma Hashmi Java Program Structure public class MyProgram {}{} // comments about the class class header must be the same As the java program name MyProgram.java class body Comments can be placed almost anywhere

Prepared by Uzma Hashmi 1-30 Java Program Structure public class MyProgram {}{} // comments about the class public static void main (String[] args) {}{} // comments about the method method header method body

Prepared by Uzma Hashmi Program.java //******************************************************************** // Program.java Author: Lewis/Loftus // // Demonstrates the basic structure of a Java application. //******************************************************************** public class Program { // // Prints a presidential quote. // public static void main (String[] args) { System.out.println ( "A quote by Abraham Lincoln:” ); //System is a predefined class that provides access to the system. //out is the output stream that is connected to the console{e.g. Monitor}. //println() - Displays the String which is passed to it. System.out.println ( "Whatever you are, be a good one.” ); }

Prepared by Uzma Hashmi 1-32 Comments Comments in a program are called inline documentation They should be included to explain the purpose of the program and describe processing steps They do not affect how a program works Java comments can take three forms: // this comment runs to the end of the line /* this comment runs to the terminating symbol, even across line breaks */ /** this is a javadoc comment */

Prepared by Uzma Hashmi 1-33 Identifiers Identifiers are the words a programmer uses in a program An identifier can be made up of letters, digits, the underscore character ( _ ), and the dollar sign Identifiers cannot begin with a digit Java is case sensitive - Total, total, and TOTAL are different identifiers By convention, programmers use different case styles for different types of identifiers, such as – title case for class names - Lincoln – upper case for constants – MAXIMUM – Combination(Compound Word)opt. - Camel Notation – E.g Class Name :MyProject

Prepared by Uzma Hashmi Identifiers cont. Often we use special identifiers called reserved words that already have a predefined meaning in the language ( such as void ) A reserved word cannot be used in any other way

Prepared by Uzma Hashmi 1-35 Reserved Words The Java reserved words: abstract assert boolean break byte case catch char class const continue default do double else enum extends false final finally float for goto if implements import instanceof int interface long native new null package private protected public return short static strictfp super switch synchronized this throw throws transient true try void volatile while

Prepared by Uzma Hashmi 1-36 White Space Spaces, blank lines, and tabs are called white space White space is used to separate words and symbols in a program Extra white space is ignored A valid Java program can be formatted many ways Programs should be formatted to enhance readability, using consistent indentation

Prepared by Uzma Hashmi //************************************************** // Poem.java // // Prints a classic poem on four lines. //************************************************** public class Poem { public static void main(String[] args) { System.out.println("Roses are red"); System.out.println("Violets are blue"); System.out.println("Sugar is sweet"); System.out.println("And so are you!"); }

Prepared by Uzma Hashmi Example for white spaces //******************************************************************** // Lincoln3.java Author: Lewis/Loftus // Demonstrates another valid program that is poorly formatted. //******************************************************************** public class Lincoln3 { public static void main ( String [] args ) { System.out.println ( "A quote by Abraham Lincoln:" ) ; System.out.println ( "Whatever you are, be a good one." ) ; }

Prepared by Uzma Hashmi Lab Assignment