SlideShare uma empresa Scribd logo
1 de 114
Primitive Data Types
Outline ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Primitive Data Types ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],boolean char double float long int short byte
Range of Primitive Data Types ,[object Object],true or false 8 bits boolean A single character (0 to 65535) 16 bits char -1.7E308 to 1.7E308 64 bits double -3.4E38 to +3.4E38 32 bits float about –10E18 to +10E18 64 bits long about –2 billion to +2billion 32 bits int -32,768 to +32,767 16 bits short -128 to +127 8 bits byte Range Size Type
Literal Constants ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Scientific Notation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Suffix: d, D, f, of F integerExponent sign E or e number sign
Character Literals ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Primitive Type Wrapper Classes ,[object Object],[object Object],[object Object],[object Object],Boolean boolean Character char Double double Float float Long long Integer int Short short Byte byte Wrapper class Primitive type
Declaration of a Variable ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The name of a Variable ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Symbolic Constants ,[object Object],[object Object],[object Object],final double SPEED_OF_LIGHT = 3.0E+10; final double CM_PER_INCH = 2.54; final int MONTH_IN_YEAR = 12;
Example Program   ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Arithmetic Operators ,[object Object],[object Object],[object Object],[object Object],Remainder of dividing op1 by op2 % Divides op1 by op2 / Multiplies op1 by op2 * Subtracts op2 from op1 - Adds op1 and op2 + Description Operator
Arithmetic Operators (Cont’d) ,[object Object],[object Object],[object Object],6 86  %  10 8.6 86.0 / 10.0 8.6 86.0 / 10 8.6 86 / 10.0 8 86 / 10 0 1 / 2 Value Arithmetic expression
Remainder with Negative Integers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Arithmetic Operator Priority ,[object Object],[object Object],[object Object],[object Object],3 +  -  (binary) 2 *  /  % 1 +  -  (unary) Priority (Precedence) Operators 0 2 – 5 + 3 -7 (2 – 5) * 5 / 2 4 3 + 7 % 2 Value Expression
Assignment Statement ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Assignment Statement (cont’d) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Writing Algebraic Expressions in Java ,[object Object],[object Object],z = (4 * x + y) / x2 – 2 * y Java expression Algebraic expression
Example1 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example2 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Making Decisions
Objectives ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Review Example 1 import java.io.*; class RestaurantBill { public static void main (String[] args) throws IOException { String charData; double basicCost; BufferedReader stdin =  new BufferedReader (  new InputStreamReader( System.in ) ); System.out.println("Enter the basic cost:"); charData  = stdin.readLine(); basicCost  = Double.parseDouble( charData  ) ; System.out.println("basic cost: " + basicCost +  " total cost: " +  (basicCost + basicCost*0.06 + basicCost*0.20)); } }
Review Example 2 import java.io.*; class SquareRoot { public static void main (String[] args) throws IOException  { String charData; double value; // read in a double BufferedReader stdin = new BufferedReader  (new InputStreamReader(System.in)); System.out.print  ("Enter a double:"); charData = stdin.readLine(); value  = Double.parseDouble( charData  ) ; // calculate its square root double result = Math.sqrt( value ); // write out the result System.out.println("square root: " + result ); } }
Control Flow ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Control Flow  (cont.) ,[object Object],[object Object],[object Object]
Control Flow  (cont.) ,[object Object],[object Object],[object Object],[object Object]
The if-else-statement ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The if-statement ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Compound Statements ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Nested if-else-statements ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Different Types of Operators ,[object Object],[object Object]
Relational Operators ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],less than or equal <= less than < greater than or equal >= greater than > not equal != equal == Meaning Operator
Logical Operators ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Logical not ! Logical or || Logical and && Meaning Operator
Logical Expressions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Operator Precedence Table ,[object Object],expr ++  expr- - Postfix ++ expr  -- expr  + expr   - expr   ! Unary new  (type) expr Creation or Cast *  /  % Multiplicative +  - Additive <  >  <=  >=   Relational ==  != Equality && Logical AND || Logical OR =  +=  -=  *=  /=  %=   Assignment Code Operator Type
Example import java . io .* ; class CookieChecker { public static void main  ( String []  args )  throws IOException {  BufferedReader stdin  =  new BufferedReader  (  new InputStreamReader (  System . in  ) ) ; //  get the number of cups of flour System . out . println (&quot; How much flour do you have? &quot;) ; String inData  =  stdin . readLine () ; int flour  =  Integer . parseInt (  inData  ) ;  //  get the number of cups of sugar System . out . println (&quot; How much sugar do you have? &quot;) ; inData  =  stdin . readLine () ; int sugar  =  Integer . parseInt (  inData  ) ;  //  check that there are enough of both ingredients if  (  flour > =  4 && sugar > =  2  ) System . out . println (&quot; Enough for cookies !&quot; ) ; else System . out . println (&quot; sorry ....&quot; ) ; } }
Making Decisions with the if  and  if...else  Structures ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Making Decisions with the if  and  if...else  Structures (continued) ,[object Object],[object Object],[object Object],[object Object]
Decision Structure Illustrating an  if  Statement
The  if...else  Structure ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The  if...else  Structure (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
An  if...else  Structure
Using Multiple Statements in an  if  or  if...else  Structure ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Erroneous Overtime Pay Calculation with Missing Curly Braces
Nesting  if  and  if...else  Statements ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Code for Bonus-Determining Decision Using Nested  if  Statements
Using Logical  AND  and  OR  Operators ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using Logical  AND  and  OR  Operators (continued) ,[object Object],[object Object],[object Object],[object Object]
Code Segment for Bonus-Determining Decision Using the  ||  Operator
Avoiding Common Errors When Making Decisions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Avoiding Common Errors When Making Decisions (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Performing Accurate and Efficient Range Checks ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Improved and Efficient Commission-Determining Logic
Using  AND  and  OR  Appropriately ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using the  switch  Statement ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using the  switch  Statement (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using the  switch  Statement (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Determining Class Status Using a  switch  Statement
Using the  switch  Statement (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using the  switch  Statement (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object]
Using the Conditional and NOT  Operators ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using the Conditional and NOT  Operators (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using the  NOT  Operator ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Understanding Precedence ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Operator Precedence for Operators Used So Far
Understanding Precedence (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object]
You Do It ,[object Object],[object Object],[object Object],[object Object],[object Object]
Iteration (Looping)
Iterative Control Flow ,[object Object],[object Object],[object Object],[object Object],[object Object]
while-statement ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
while-statement  (cont) ,[object Object],[object Object],[object Object],int count = 1;  // start count out at one while ( count <= 3 )  // loop while count is <= 3 { System.out.println( &quot;count is:&quot; + count ); count = count + 1;  // add one to count } System.out.println( &quot;Done with the loop&quot; );
A Complete Example 1 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Counting Upward/Downward ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Infinite Loop ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
A Complete Example 2 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Nested Loops ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Sentinel Controlled Loops ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Improve the code so that the prompt says: “Enter the 1st integer”,  “ Enter the 2nd integer”,  “Enter the 3rd integer”, and so on.
Sentinel Controlled Loops, Cont’d ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Result-controlled Loops  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Computing the root of 3.0
Learning About the Loop Structure ,[object Object],[object Object],[object Object],[object Object],[object Object]
Learning About the Loop Structure (continued) ,[object Object],[object Object],[object Object],[object Object]
Flowchart of a Loop Structure
Using a  while  Loop To Create a Definite Loop ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
A  while  Loop that Prints the Integers 1 through 10
Using a  while  Loop To Create a Definite Loop (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using a  while  Loop To Create a Definite Loop (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
A Loop that Displays “Hello” Infinitely
Using a  while  Loop To Create a Definite Loop (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using a  while  Loop To Create a Definite Loop (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
A  while  Loop that Prints “Hello” Infinitely Because  loopCount  is Not Altered in the Loop Body
Using a  while  Loop To Create a Definite Loop (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
A  while  Loop that Loops Infinitely with No Output Because the Loop Body is Empty
Using a  while  Loop To Create a Definite Loop (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
A  while  Loop that Prints “Hello” Twice, Decrementing the  loopCount  Variable in the Loop Body
Using a  while  Loop to Create an Indefinite Loop ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using Shortcut Arithmetic Operators ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using Shortcut Arithmetic Operators (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Four Ways to Add 1 to a Value
Using Shortcut Arithmetic Operators (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using a  for  Loop ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
A  for  Loop that Prints the Integers 1 through 10
Using a  for  Loop (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using a  for  Loop (continued) ,[object Object],[object Object],[object Object],[object Object]
Using a  for  Loop (continued) ,[object Object],[object Object],[object Object],[object Object]
Learning How and When to Use a  do...while  Loop ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
General Structure of a  do...while  Loop
Learning About Nested Loops ,[object Object],[object Object],[object Object],[object Object],[object Object]
Learning About Nested Loops (continued) ,[object Object],[object Object],[object Object],[object Object]
Nested Loops
Improving Loop Performance ,[object Object],[object Object],[object Object],[object Object]
Improving Loop Performance (continued) ,[object Object],[object Object],[object Object],[object Object]
You Do It ,[object Object],[object Object],[object Object],[object Object],[object Object]

Mais conteúdo relacionado

Mais procurados

Branching statements
Branching statementsBranching statements
Branching statements
ArunMK17
 

Mais procurados (20)

Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C Programming
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
ITFT-Constants, variables and data types in java
ITFT-Constants, variables and data types in javaITFT-Constants, variables and data types in java
ITFT-Constants, variables and data types in java
 
Data Types, Variables, and Operators
Data Types, Variables, and OperatorsData Types, Variables, and Operators
Data Types, Variables, and Operators
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#
 
Decision Making Statement in C ppt
Decision Making Statement in C pptDecision Making Statement in C ppt
Decision Making Statement in C ppt
 
Java Tokens
Java  TokensJava  Tokens
Java Tokens
 
C++ string
C++ stringC++ string
C++ string
 
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdfMANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
 
Branching statements
Branching statementsBranching statements
Branching statements
 
Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional array
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
 
String in java
String in javaString in java
String in java
 
Constants in java
Constants in javaConstants in java
Constants in java
 
C# Strings
C# StringsC# Strings
C# Strings
 
Variables in C and C++ Language
Variables in C and C++ LanguageVariables in C and C++ Language
Variables in C and C++ Language
 
Array and string
Array and stringArray and string
Array and string
 
Wrapper classes
Wrapper classes Wrapper classes
Wrapper classes
 
Array Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional arrayArray Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional array
 

Destaque

Constants, Variables and Data Types in Java
Constants, Variables and Data Types in JavaConstants, Variables and Data Types in Java
Constants, Variables and Data Types in Java
Abhilash Nair
 
Introduction to the Algorithm Game
Introduction to the Algorithm GameIntroduction to the Algorithm Game
Introduction to the Algorithm Game
Ivan Orozco
 
Our presentation on algorithm design
Our presentation on algorithm designOur presentation on algorithm design
Our presentation on algorithm design
Nahid Hasan
 
Java Collections
Java CollectionsJava Collections
Java Collections
parag
 
DESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSDESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMS
Gayathri Gaayu
 
Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Language
jaimefrozr
 

Destaque (20)

Constants, Variables and Data Types in Java
Constants, Variables and Data Types in JavaConstants, Variables and Data Types in Java
Constants, Variables and Data Types in Java
 
Introduction to the Algorithm Game
Introduction to the Algorithm GameIntroduction to the Algorithm Game
Introduction to the Algorithm Game
 
Ajax 101 Workshop
Ajax 101 WorkshopAjax 101 Workshop
Ajax 101 Workshop
 
Java tutorial for Beginners and Entry Level
Java tutorial for Beginners and Entry LevelJava tutorial for Beginners and Entry Level
Java tutorial for Beginners and Entry Level
 
07 java collection
07 java collection07 java collection
07 java collection
 
1 java - data type
1  java - data type1  java - data type
1 java - data type
 
Data types
Data typesData types
Data types
 
Our presentation on algorithm design
Our presentation on algorithm designOur presentation on algorithm design
Our presentation on algorithm design
 
Java Collections
Java CollectionsJava Collections
Java Collections
 
Java Datatypes
Java DatatypesJava Datatypes
Java Datatypes
 
Built in classes in java
Built in classes in javaBuilt in classes in java
Built in classes in java
 
Java Collections API
Java Collections APIJava Collections API
Java Collections API
 
Basic java tutorial
Basic java tutorialBasic java tutorial
Basic java tutorial
 
The various forms of data
The various forms of dataThe various forms of data
The various forms of data
 
DESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSDESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMS
 
Algorithm.ppt
Algorithm.pptAlgorithm.ppt
Algorithm.ppt
 
java swing tutorial for beginners(java programming tutorials)
java swing tutorial for beginners(java programming tutorials)java swing tutorial for beginners(java programming tutorials)
java swing tutorial for beginners(java programming tutorials)
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to Algorithms
 
Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Language
 

Semelhante a Java: Primitive Data Types

presentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptxpresentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptx
KrishanPalSingh39
 
component of c language.pptx
component of c language.pptxcomponent of c language.pptx
component of c language.pptx
AnisZahirahAzman
 
Object Oriented Programming with C++
Object Oriented Programming with C++Object Oriented Programming with C++
Object Oriented Programming with C++
Rokonuzzaman Rony
 
Ap Power Point Chpt2
Ap Power Point Chpt2Ap Power Point Chpt2
Ap Power Point Chpt2
dplunkett
 
The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Language
zone
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoo
birbal
 

Semelhante a Java: Primitive Data Types (20)

Token and operators
Token and operatorsToken and operators
Token and operators
 
Basic
BasicBasic
Basic
 
presentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptxpresentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptx
 
component of c language.pptx
component of c language.pptxcomponent of c language.pptx
component of c language.pptx
 
Object Oriented Programming with C++
Object Oriented Programming with C++Object Oriented Programming with C++
Object Oriented Programming with C++
 
lecture2.ppt
lecture2.pptlecture2.ppt
lecture2.ppt
 
Chapter-2 is for tokens in C programming
Chapter-2 is for tokens in C programmingChapter-2 is for tokens in C programming
Chapter-2 is for tokens in C programming
 
CSharp Language Overview Part 1
CSharp Language Overview Part 1CSharp Language Overview Part 1
CSharp Language Overview Part 1
 
Ap Power Point Chpt2
Ap Power Point Chpt2Ap Power Point Chpt2
Ap Power Point Chpt2
 
parts_of_python_programming_language.pptx
parts_of_python_programming_language.pptxparts_of_python_programming_language.pptx
parts_of_python_programming_language.pptx
 
C language
C languageC language
C language
 
C++ programming
C++ programmingC++ programming
C++ programming
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
C# overview part 1
C# overview part 1C# overview part 1
C# overview part 1
 
C program
C programC program
C program
 
Fortran 90 Basics
Fortran 90 BasicsFortran 90 Basics
Fortran 90 Basics
 
The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Language
 
Les origines de Javascript
Les origines de JavascriptLes origines de Javascript
Les origines de Javascript
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoo
 

Mais de Tareq Hasan

08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt
Tareq Hasan
 
02 c++ Array Pointer
02 c++ Array Pointer02 c++ Array Pointer
02 c++ Array Pointer
Tareq Hasan
 
01 c++ Intro.ppt
01 c++ Intro.ppt01 c++ Intro.ppt
01 c++ Intro.ppt
Tareq Hasan
 
Algorithm: priority queue
Algorithm: priority queueAlgorithm: priority queue
Algorithm: priority queue
Tareq Hasan
 

Mais de Tareq Hasan (20)

Grow Your Career with WordPress
Grow Your Career with WordPressGrow Your Career with WordPress
Grow Your Career with WordPress
 
Caching in WordPress
Caching in WordPressCaching in WordPress
Caching in WordPress
 
How to Submit a plugin to WordPress.org Repository
How to Submit a plugin to WordPress.org RepositoryHow to Submit a plugin to WordPress.org Repository
How to Submit a plugin to WordPress.org Repository
 
Composer - The missing package manager for PHP
Composer - The missing package manager for PHPComposer - The missing package manager for PHP
Composer - The missing package manager for PHP
 
WordPress Theme & Plugin development best practices - phpXperts seminar 2011
WordPress Theme & Plugin development best practices - phpXperts seminar 2011WordPress Theme & Plugin development best practices - phpXperts seminar 2011
WordPress Theme & Plugin development best practices - phpXperts seminar 2011
 
08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt
 
02 c++ Array Pointer
02 c++ Array Pointer02 c++ Array Pointer
02 c++ Array Pointer
 
01 c++ Intro.ppt
01 c++ Intro.ppt01 c++ Intro.ppt
01 c++ Intro.ppt
 
chapter22.ppt
chapter22.pptchapter22.ppt
chapter22.ppt
 
chapter - 6.ppt
chapter - 6.pptchapter - 6.ppt
chapter - 6.ppt
 
chapter-8.ppt
chapter-8.pptchapter-8.ppt
chapter-8.ppt
 
chapter23.ppt
chapter23.pptchapter23.ppt
chapter23.ppt
 
chapter24.ppt
chapter24.pptchapter24.ppt
chapter24.ppt
 
Algorithm: priority queue
Algorithm: priority queueAlgorithm: priority queue
Algorithm: priority queue
 
Algorithm: Quick-Sort
Algorithm: Quick-SortAlgorithm: Quick-Sort
Algorithm: Quick-Sort
 
Java: GUI
Java: GUIJava: GUI
Java: GUI
 
Java: Inheritance
Java: InheritanceJava: Inheritance
Java: Inheritance
 
Java: Exception
Java: ExceptionJava: Exception
Java: Exception
 
Java: Introduction to Arrays
Java: Introduction to ArraysJava: Introduction to Arrays
Java: Introduction to Arrays
 
Java: Class Design Examples
Java: Class Design ExamplesJava: Class Design Examples
Java: Class Design Examples
 

Último

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Último (20)

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 

Java: Primitive Data Types

  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 23.
  • 24. Review Example 1 import java.io.*; class RestaurantBill { public static void main (String[] args) throws IOException { String charData; double basicCost; BufferedReader stdin = new BufferedReader ( new InputStreamReader( System.in ) ); System.out.println(&quot;Enter the basic cost:&quot;); charData = stdin.readLine(); basicCost = Double.parseDouble( charData ) ; System.out.println(&quot;basic cost: &quot; + basicCost + &quot; total cost: &quot; + (basicCost + basicCost*0.06 + basicCost*0.20)); } }
  • 25. Review Example 2 import java.io.*; class SquareRoot { public static void main (String[] args) throws IOException { String charData; double value; // read in a double BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in)); System.out.print (&quot;Enter a double:&quot;); charData = stdin.readLine(); value = Double.parseDouble( charData ) ; // calculate its square root double result = Math.sqrt( value ); // write out the result System.out.println(&quot;square root: &quot; + result ); } }
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38. Example import java . io .* ; class CookieChecker { public static void main ( String [] args ) throws IOException { BufferedReader stdin = new BufferedReader ( new InputStreamReader ( System . in ) ) ; // get the number of cups of flour System . out . println (&quot; How much flour do you have? &quot;) ; String inData = stdin . readLine () ; int flour = Integer . parseInt ( inData ) ; // get the number of cups of sugar System . out . println (&quot; How much sugar do you have? &quot;) ; inData = stdin . readLine () ; int sugar = Integer . parseInt ( inData ) ; // check that there are enough of both ingredients if ( flour > = 4 && sugar > = 2 ) System . out . println (&quot; Enough for cookies !&quot; ) ; else System . out . println (&quot; sorry ....&quot; ) ; } }
  • 39.
  • 40.
  • 42.
  • 43.
  • 44. An if...else Structure
  • 45.
  • 46. Erroneous Overtime Pay Calculation with Missing Curly Braces
  • 47.
  • 48. Code for Bonus-Determining Decision Using Nested if Statements
  • 49.
  • 50.
  • 51. Code Segment for Bonus-Determining Decision Using the || Operator
  • 52.
  • 53.
  • 54.
  • 55. Improved and Efficient Commission-Determining Logic
  • 56.
  • 57.
  • 58.
  • 59.
  • 60. Determining Class Status Using a switch Statement
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67. Operator Precedence for Operators Used So Far
  • 68.
  • 69.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84. Flowchart of a Loop Structure
  • 85.
  • 86. A while Loop that Prints the Integers 1 through 10
  • 87.
  • 88.
  • 89. A Loop that Displays “Hello” Infinitely
  • 90.
  • 91.
  • 92. A while Loop that Prints “Hello” Infinitely Because loopCount is Not Altered in the Loop Body
  • 93.
  • 94. A while Loop that Loops Infinitely with No Output Because the Loop Body is Empty
  • 95.
  • 96. A while Loop that Prints “Hello” Twice, Decrementing the loopCount Variable in the Loop Body
  • 97.
  • 98.
  • 99.
  • 100. Four Ways to Add 1 to a Value
  • 101.
  • 102.
  • 103. A for Loop that Prints the Integers 1 through 10
  • 104.
  • 105.
  • 106.
  • 107.
  • 108. General Structure of a do...while Loop
  • 109.
  • 110.
  • 112.
  • 113.
  • 114.