Dale Roberts Introduction to Java - Input, Program Control and Instantiation Dale Roberts, Lecturer Computer Science, IUPUI

Slides:



Advertisements
Similar presentations
 2005 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Advertisements

Dale Roberts Introduction to Java - First Program Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.
Lecture 2 Introduction to C Programming
Introduction to C Programming
 2005 Pearson Education, Inc. All rights reserved Introduction.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
Introduction to C Programming
Dale Roberts Object Oriented Programming using Java - Inheritance Constructors Dale Roberts, Lecturer Computer Science, IUPUI
Chapter 2 - Introduction to Java Applications
 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
 Pearson Education, Inc. All rights reserved. 3 3 Introduction to Classes and Objects.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
Chapter 2 - Introduction to Java Applications
Introduction to C Programming
 2005 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Dale Roberts Object Oriented Programming using Java - Class Constructors Dale Roberts, Lecturer Computer Science, IUPUI Department.
Introduction to Java Java SE 8 for Programmers Paul Deitel Harvey Deitel Deitel Developer Series 2014.
Java Applications & Program Design
 2005 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
 2005 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Java™ How to Program, 9/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Android How to Program, 2/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Dale Roberts Procedural Programming using Java Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.
C How to Program, 6/e © by Pearson Education, Inc. All Rights Reserved.
Dale Roberts Object Oriented Programming using Java - Packages Dale Roberts, Lecturer Computer Science, IUPUI Department.
Dale Roberts Introduction to Java - Access Specifiers Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Dale Roberts Program Control using Java - Boolean Expressions Dale Roberts, Lecturer Computer Science, IUPUI Department of.
Dale Roberts Object Oriented Programming using Java - Enumerations Dale Roberts, Lecturer Computer Science, IUPUI Department.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
Introduction to C Programming Angela Chih-Wei Tang ( 唐 之 瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2010 Fall.
Dale Roberts Program Control using Java - Selection Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer.
 2000 Prentice Hall, Inc. All rights reserved. 1 Chapter 2 - Introduction to Java Applications Outline 2.1Introduction 2.2A Simple Program: Printing a.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Lecture 2: Introduction to C Programming. OBJECTIVES In this lecture you will learn:  To use simple input and output statements.  The fundamental data.
Lecture 2: Introduction to C Programming. OBJECTIVES In this lecture you will learn:  To use simple input and output statements.  The fundamental data.
Dale Roberts Object Oriented Programming using Java - OOD to OOP: ATM Case Study Dale Roberts, Lecturer Computer Science, IUPUI
Java™ How to Program, 10/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Dale Roberts Program Control using Java - Repetition Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer.
CSC 1051 – Algorithms and Data Structures I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
 2005 Pearson Education, Inc. All rights reserved. 1 Introduction to Classes and Objects.
 2005 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
 2005 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
CCSA 221 Programming in C CHAPTER 3 COMPILING AND RUNNING YOUR FIRST PROGRAM 1 ALHANOUF ALAMR.
 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Introduction to Java Applications
3 Introduction to Classes and Objects.
Chapter 2 - Introduction to C Programming
Yanal Alahmad Java Workshop Yanal Alahmad
2.5 Another Java Application: Adding Integers
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
MSIS 655 Advanced Business Applications Programming
1) C program development 2) Selection structure
Chapter 2 - Introduction to C Programming
Introduction to Java Applications
Programming Concepts and Database
Object Oriented Programming in java
Chapter 2 - Introduction to C Programming
Dale Roberts, Lecturer IUPUI
Introduction to C Programming
Presentation transcript:

Dale Roberts Introduction to Java - Input, Program Control and Instantiation Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and Information Science, School of Science, IUPUI

Dale Roberts Another Java Application: Adding Integers Upcoming program Use Scanner to read two integers from user Use printf to display sum of the two values Use packages

Dale Roberts 3Outline nextInt import declaration imports class Scanner from package java.util. Declare and initialize variable input, which is a Scanner. Declare variables number1, number2 and sum. Read an integer from the user and assign it to number1.

Dale Roberts 4Outline Addition. java (2 of 2) 4. Addition 5. printf Read an integer from the user and assign it to number2. Calculate the sum of the variables number1 and number2, assign result to sum. Display the sum using formatted output. Two integers entered by the user.

Dale Roberts Decision Making: Equality and Relational Operators Condition Expression can be either true or false if statement Simple version in this section, more detail later If a condition is true, then the body of the if statement executed Control always resumes after the if statement Conditions in if statements can be formed using equality or relational operators (next slide)

Dale Roberts 6 Fig | Equality and relational operators.

Dale Roberts 7Outline Comp arison.java (1 of 2) 1. Class Comparison 1.1 main 1.2 Declarations 1.3 Input data (nextInt) 1.4 Compare two inputs using if statements Test for equality, display result using printf. Compares two numbers using relational operator <.

Dale Roberts 8Outline Comparison. java (2 of 2) Program output Compares two numbers using relational operators >, =.

Dale Roberts 9 Declaring a Class with a Method and Instantiating an Object of a Class Each class declaration that begins with keyword public must be stored in a file that has the same name as the class and ends with the.java file-name extension.

Dale Roberts 10Outline GradeB ook.java Print line of text to output

Dale Roberts 11Outline GradeB ookTest.java Use class instance creation expression to create object of class GradeBook Call method displayMessage using GradeBook object

Dale Roberts 12 Compiling an Application with Multiple Classes Compiling multiple classes List each.java file in the compilation command and separate them with spaces Compile with *.java to compile all.java files in that directory

Dale Roberts 13 Notes on Import Declarations java.lang is implicitly imported into every program Default package Contains classes compiled in the same directory Implicitly imported into source code of other files in directory Imports unnecessary if fully-qualified names are used

Dale Roberts Acknowledgements Pearson Education, Lewis and Loftus. Deitel, Java How to Program /language.impl.overview.pdf