SlideShare a Scribd company logo
1 of 51
Chapter 3 Numerical Data
Objectives ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Manipulating Numbers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Variables ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Numerical Data Types ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Data Type Precisions The six data types differ in the precision of values they can store in memory.
Assignment Statements ,[object Object],[object Object],[object Object],[object Object],[object Object]
Arithmetic Operators ,[object Object],This is an integer division where the fractional part is truncated.
Arithmetic Expression ,[object Object],[object Object],[object Object],[object Object],[object Object]
Precedence Rules
Type Casting ,[object Object],[object Object],[object Object],[object Object],[object Object]
Explicit Type Casting ,[object Object],[object Object],[object Object],[object Object],[object Object],Type case  x  to  float  and then divide it by 3. Type cast the result of the expression  x / y * 3.0  to  int .
Implicit Type Casting ,[object Object],[object Object],[object Object],[object Object],[object Object],A higher precision value cannot be assigned to a lower precision variable.
Constants ,[object Object],[object Object],These are constants, also called  named constant . The reserved word  final  is used to declare constants. These are called  literal constant.
Primitive vs. Reference ,[object Object],[object Object]
Primitive Data Declaration and Assignments Code State of Memory int firstNumber, secondNumber; firstNumber  = 234; secondNumber = 87; A B firstNumber secondNumber A.  Variables are  allocated in memory. B.  Values are assigned  to variables. 234 87
Assigning Numerical Data Code State of Memory int number; number = 237; number A.  The variable  is allocated in  memory. B.  The value  237   is assigned to  number . 237 A B C number = 35; C.  The value  35   overwrites the previous value  237. 35
Assigning Objects Code State of Memory Customer customer; customer = new Customer( ); customer = new Customer( ); customer A.  The variable  is  allocated in memory. A B C B.  The reference to the  new object is assigned  to  customer . Customer C.  The reference to another object overwrites the reference in  customer. Customer
Having Two References to a Single Object Code State of Memory Customer clemens, twain, clemens = new Customer( ); twain  = clemens; A B C A.  Variables are  allocated in memory. clemens twain B.  The reference to the  new object is assigned  to  clemens . Customer C.  The reference in  clemens  is assigned to  customer.
Type Mismatch ,[object Object],[object Object],int   age; age = JOptionPane.showInputDialog( null , “Enter your age”);
Type Conversion ,[object Object],int   age; String  inputStr; inputStr = JOptionPane.showInputDialog( null , “Enter your age”); age = Integer.parseInt(inputStr);
Other Conversion Methods
Sample Code Fragment //code fragment to input radius and output //area and circumference double  radius, area, circumference; radiusStr = JOptionPane.showInputDialog( null ,  "Enter radius: "  ); radius = Double.parseDouble(radiusStr); //compute area and circumference area = PI * radius * radius; circumference = 2.0 * PI * radius; JOptionPane.showMessageDialog( null ,  "Given Radius:  "  + radius +  ""  +  "Area:  "  + area  +  ""  +  "Circumference: "  + circumference);
Overloaded Operator + ,[object Object],[object Object],[object Object],output = “test” + 1 + 2; output = 1 + 2 + “test”;
The DecimalFormat Class ,[object Object],double num = 123.45789345; DecimalFormat df = new DecimalFormat(“0.000”); //three decimal places System.out.print ( num ) ; System.out.print ( df.format ( num )) ; 123.45789345   123.458
3.5 Standard Output ,[object Object],[object Object]
Standard Output Window ,[object Object],[object Object]
The print Method ,[object Object],[object Object],[object Object],[object Object]
The println Method ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Standard Input ,[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],Common Scanner Methods:
The Math class ,[object Object],double   num, x, y; x = …; y = …; num = Math.sqrt(Math.max(x, y) + 12.4);
Some Math Class Methods Table 3.8 page 113 in the textbook contains a list of class methods defined in the  Math  class. The sine of  a . (Note: all trigonometric functions are computed in radians) sin(a) The square root of  a . sqrt(a) The larger of a and b. max(a,b) Natural logarithm (base  e ) of  a . log(a) The number  a  raised to the power of  b . pow(a,b) Natural number  e  raised to the power of  a . exp(a) The largest whole number less than or equal to  a . floor(a) Description Method
Computing the Height of a Pole alphaRad = Math.toRadians ( alpha ) ; betaRad  = Math.toRadians ( beta ) ; height =  (  distance * Math.sin ( alphaRad )  * Math.sin ( betaRad ) ) / Math.sqrt (  Math.sin ( alphaRad + betaRad )  * Math.sin ( alphaRad - betaRad ) ) ;
The GregorianCalendar Class ,[object Object],GregorianCalendar today, independenceDay; today  =  new  GregorianCalendar () ; independenceDay  =  new  GregorianCalendar ( 1776, 6, 4 ) ; //month 6 means July; 0 means January
Retrieving Calendar Information ,[object Object]
Sample Calendar Retrieval GregorianCalendar cal =  new  GregorianCalendar () ; //Assume today is Nov 9, 2003 System.out.print(“Today is ” + (cal.get(Calendar.MONTH)+1) + “/” + cal.get(Calendar.DATE) + “/” + cal.get(Calendar.YEAR)); Today is 11/9/2003 Output
Problem Statement ,[object Object],[object Object]
Overall Plan ,[object Object],[object Object],[object Object],[object Object]
Required Classes
Development Steps ,[object Object],[object Object],[object Object],[object Object],[object Object]
Step 1 Design ,[object Object],[object Object],[object Object],[object Object],[object Object],int in years loan period double in percent (e.g.,12.5) annual interest rate double dollars and cents loan amount Data Type Format Input
Step 1 Code ,[object Object],[object Object],Program source file is too big to list here. From now on, we ask you to view the source files using your Java IDE.
Step 1 Test ,[object Object],[object Object],[object Object]
Step 2 Design ,[object Object],[object Object]
Step 2 Code ,[object Object],[object Object]
Step 2 Test ,[object Object],[object Object]
Step 3 Design ,[object Object],[object Object],[object Object]
Step 3 Code ,[object Object],[object Object]
Step 3 Test ,[object Object]
Step 4: Finalize ,[object Object],[object Object],[object Object],[object Object]

More Related Content

What's hot

What's hot (20)

The Basics of MATLAB
The Basics of MATLABThe Basics of MATLAB
The Basics of MATLAB
 
Data mining assignment 4
Data mining assignment 4Data mining assignment 4
Data mining assignment 4
 
Introduction to Arrays in C
Introduction to Arrays in CIntroduction to Arrays in C
Introduction to Arrays in C
 
Array
ArrayArray
Array
 
Ch3
Ch3Ch3
Ch3
 
Visual basic bt0082
Visual basic  bt0082Visual basic  bt0082
Visual basic bt0082
 
Variables and calculations_chpt_4
Variables and calculations_chpt_4Variables and calculations_chpt_4
Variables and calculations_chpt_4
 
Data mining assignment 5
Data mining assignment 5Data mining assignment 5
Data mining assignment 5
 
Probability Assignment Help
Probability Assignment HelpProbability Assignment Help
Probability Assignment Help
 
Arrays 1D and 2D , and multi dimensional
Arrays 1D and 2D , and multi dimensional Arrays 1D and 2D , and multi dimensional
Arrays 1D and 2D , and multi dimensional
 
Savitch Ch 02
Savitch Ch 02Savitch Ch 02
Savitch Ch 02
 
4 linear regeression with multiple variables
4 linear regeression with multiple variables4 linear regeression with multiple variables
4 linear regeression with multiple variables
 
Arrays & Strings
Arrays & StringsArrays & Strings
Arrays & Strings
 
R교육1
R교육1R교육1
R교육1
 
Operators , Functions and Options in VB.NET
Operators , Functions and Options in VB.NETOperators , Functions and Options in VB.NET
Operators , Functions and Options in VB.NET
 
design and analysis of algorithm
design and analysis of algorithmdesign and analysis of algorithm
design and analysis of algorithm
 
01 Notes Introduction Analysis of Algorithms Notes
01 Notes Introduction Analysis of Algorithms Notes01 Notes Introduction Analysis of Algorithms Notes
01 Notes Introduction Analysis of Algorithms Notes
 
Machnical Engineering Assignment Help
Machnical Engineering Assignment HelpMachnical Engineering Assignment Help
Machnical Engineering Assignment Help
 
Arrays C#
Arrays C#Arrays C#
Arrays C#
 
02 Notes Divide and Conquer
02 Notes Divide and Conquer02 Notes Divide and Conquer
02 Notes Divide and Conquer
 

Viewers also liked

CUIDADO DE ENFERMERIA Y PROMOCION DE LA SALUD
CUIDADO DE ENFERMERIA Y PROMOCION DE LA SALUDCUIDADO DE ENFERMERIA Y PROMOCION DE LA SALUD
CUIDADO DE ENFERMERIA Y PROMOCION DE LA SALUDCECILIA SANCHEZ
 
Master thesis: Developing strategic relationships at Volvo Powertrain
Master thesis: Developing strategic relationships at Volvo PowertrainMaster thesis: Developing strategic relationships at Volvo Powertrain
Master thesis: Developing strategic relationships at Volvo PowertrainKarl Tiselius
 

Viewers also liked (6)

Excepionalities
ExcepionalitiesExcepionalities
Excepionalities
 
Marketing
MarketingMarketing
Marketing
 
Reasoning Skills
Reasoning SkillsReasoning Skills
Reasoning Skills
 
CUIDADO DE ENFERMERIA Y PROMOCION DE LA SALUD
CUIDADO DE ENFERMERIA Y PROMOCION DE LA SALUDCUIDADO DE ENFERMERIA Y PROMOCION DE LA SALUD
CUIDADO DE ENFERMERIA Y PROMOCION DE LA SALUD
 
Chapter one
Chapter oneChapter one
Chapter one
 
Master thesis: Developing strategic relationships at Volvo Powertrain
Master thesis: Developing strategic relationships at Volvo PowertrainMaster thesis: Developing strategic relationships at Volvo Powertrain
Master thesis: Developing strategic relationships at Volvo Powertrain
 

Similar to Java căn bản - Chapter3

Ap Power Point Chpt2
Ap Power Point Chpt2Ap Power Point Chpt2
Ap Power Point Chpt2dplunkett
 
3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx
3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx
3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptxganeshkarthy
 
VCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxVCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxskilljiolms
 
Csharp4 operators and_casts
Csharp4 operators and_castsCsharp4 operators and_casts
Csharp4 operators and_castsAbed Bukhari
 
VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2YOGESH SINGH
 
Java: Primitive Data Types
Java: Primitive Data TypesJava: Primitive Data Types
Java: Primitive Data TypesTareq Hasan
 
C++ - UNIT_-_IV.pptx which contains details about Pointers
C++ - UNIT_-_IV.pptx which contains details about PointersC++ - UNIT_-_IV.pptx which contains details about Pointers
C++ - UNIT_-_IV.pptx which contains details about PointersANUSUYA S
 
C++ Programming Homework Help
C++ Programming Homework HelpC++ Programming Homework Help
C++ Programming Homework HelpC++ Homework Help
 
Data types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in javaData types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in javaJaved Rashid
 
Arrays-Computer programming
Arrays-Computer programmingArrays-Computer programming
Arrays-Computer programmingnmahi96
 

Similar to Java căn bản - Chapter3 (20)

130717666736980000
130717666736980000130717666736980000
130717666736980000
 
Ap Power Point Chpt2
Ap Power Point Chpt2Ap Power Point Chpt2
Ap Power Point Chpt2
 
vb.net.pdf
vb.net.pdfvb.net.pdf
vb.net.pdf
 
3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx
3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx
3Arrays, Declarations, Expressions, Statements, Symbolic constant.pptx
 
Ch03
Ch03Ch03
Ch03
 
Python
PythonPython
Python
 
VCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxVCE Unit 01 (2).pptx
VCE Unit 01 (2).pptx
 
Csharp4 operators and_casts
Csharp4 operators and_castsCsharp4 operators and_casts
Csharp4 operators and_casts
 
VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2
 
Get Fast C++ Homework Help
Get Fast C++ Homework HelpGet Fast C++ Homework Help
Get Fast C++ Homework Help
 
Java: Primitive Data Types
Java: Primitive Data TypesJava: Primitive Data Types
Java: Primitive Data Types
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
 
C++ - UNIT_-_IV.pptx which contains details about Pointers
C++ - UNIT_-_IV.pptx which contains details about PointersC++ - UNIT_-_IV.pptx which contains details about Pointers
C++ - UNIT_-_IV.pptx which contains details about Pointers
 
CHAPTER 5
CHAPTER 5CHAPTER 5
CHAPTER 5
 
C++ programming
C++ programmingC++ programming
C++ programming
 
Array
ArrayArray
Array
 
Chapter1.pptx
Chapter1.pptxChapter1.pptx
Chapter1.pptx
 
C++ Programming Homework Help
C++ Programming Homework HelpC++ Programming Homework Help
C++ Programming Homework Help
 
Data types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in javaData types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in java
 
Arrays-Computer programming
Arrays-Computer programmingArrays-Computer programming
Arrays-Computer programming
 

More from Vince Vo

Java căn bản - Chapter13
Java căn bản - Chapter13Java căn bản - Chapter13
Java căn bản - Chapter13Vince Vo
 
Java căn bản - Chapter12
Java căn bản - Chapter12Java căn bản - Chapter12
Java căn bản - Chapter12Vince Vo
 
Java căn bản - Chapter10
Java căn bản - Chapter10Java căn bản - Chapter10
Java căn bản - Chapter10Vince Vo
 
Java căn bản - Chapter9
Java căn bản - Chapter9Java căn bản - Chapter9
Java căn bản - Chapter9Vince Vo
 
Java căn bản - Chapter8
Java căn bản - Chapter8Java căn bản - Chapter8
Java căn bản - Chapter8Vince Vo
 
Java căn bản - Chapter7
Java căn bản - Chapter7Java căn bản - Chapter7
Java căn bản - Chapter7Vince Vo
 
Java căn bản - Chapter6
Java căn bản - Chapter6Java căn bản - Chapter6
Java căn bản - Chapter6Vince Vo
 
Java căn bản - Chapter5
Java căn bản - Chapter5Java căn bản - Chapter5
Java căn bản - Chapter5Vince Vo
 
Java căn bản - Chapter4
Java căn bản - Chapter4Java căn bản - Chapter4
Java căn bản - Chapter4Vince Vo
 
Java căn bản - Chapter2
Java căn bản - Chapter2Java căn bản - Chapter2
Java căn bản - Chapter2Vince Vo
 
Java căn bản- Chapter1
Java  căn bản- Chapter1Java  căn bản- Chapter1
Java căn bản- Chapter1Vince Vo
 
Hướng dẫn cài đặt Java
Hướng dẫn cài đặt JavaHướng dẫn cài đặt Java
Hướng dẫn cài đặt JavaVince Vo
 

More from Vince Vo (20)

Java căn bản - Chapter13
Java căn bản - Chapter13Java căn bản - Chapter13
Java căn bản - Chapter13
 
Java căn bản - Chapter12
Java căn bản - Chapter12Java căn bản - Chapter12
Java căn bản - Chapter12
 
Java căn bản - Chapter10
Java căn bản - Chapter10Java căn bản - Chapter10
Java căn bản - Chapter10
 
Java căn bản - Chapter9
Java căn bản - Chapter9Java căn bản - Chapter9
Java căn bản - Chapter9
 
Java căn bản - Chapter8
Java căn bản - Chapter8Java căn bản - Chapter8
Java căn bản - Chapter8
 
Java căn bản - Chapter7
Java căn bản - Chapter7Java căn bản - Chapter7
Java căn bản - Chapter7
 
Java căn bản - Chapter6
Java căn bản - Chapter6Java căn bản - Chapter6
Java căn bản - Chapter6
 
Java căn bản - Chapter5
Java căn bản - Chapter5Java căn bản - Chapter5
Java căn bản - Chapter5
 
Java căn bản - Chapter4
Java căn bản - Chapter4Java căn bản - Chapter4
Java căn bản - Chapter4
 
Java căn bản - Chapter2
Java căn bản - Chapter2Java căn bản - Chapter2
Java căn bản - Chapter2
 
Java căn bản- Chapter1
Java  căn bản- Chapter1Java  căn bản- Chapter1
Java căn bản- Chapter1
 
Hướng dẫn cài đặt Java
Hướng dẫn cài đặt JavaHướng dẫn cài đặt Java
Hướng dẫn cài đặt Java
 
Rama Ch14
Rama Ch14Rama Ch14
Rama Ch14
 
Rama Ch13
Rama Ch13Rama Ch13
Rama Ch13
 
Rama Ch12
Rama Ch12Rama Ch12
Rama Ch12
 
Rama Ch12
Rama Ch12Rama Ch12
Rama Ch12
 
Rama Ch11
Rama Ch11Rama Ch11
Rama Ch11
 
Rama Ch10
Rama Ch10Rama Ch10
Rama Ch10
 
Rama Ch8
Rama Ch8Rama Ch8
Rama Ch8
 
Rama Ch9
Rama Ch9Rama Ch9
Rama Ch9
 

Recently uploaded

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
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 . pdfQucHHunhnh
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
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 Delhikauryashika82
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
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.christianmathematics
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 

Recently uploaded (20)

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
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
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
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
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
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
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
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.
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
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"
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 

Java căn bản - Chapter3

  • 2.
  • 3.
  • 4.
  • 5.
  • 6. Data Type Precisions The six data types differ in the precision of values they can store in memory.
  • 7.
  • 8.
  • 9.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16. Primitive Data Declaration and Assignments Code State of Memory int firstNumber, secondNumber; firstNumber = 234; secondNumber = 87; A B firstNumber secondNumber A. Variables are allocated in memory. B. Values are assigned to variables. 234 87
  • 17. Assigning Numerical Data Code State of Memory int number; number = 237; number A. The variable is allocated in memory. B. The value 237 is assigned to number . 237 A B C number = 35; C. The value 35 overwrites the previous value 237. 35
  • 18. Assigning Objects Code State of Memory Customer customer; customer = new Customer( ); customer = new Customer( ); customer A. The variable is allocated in memory. A B C B. The reference to the new object is assigned to customer . Customer C. The reference to another object overwrites the reference in customer. Customer
  • 19. Having Two References to a Single Object Code State of Memory Customer clemens, twain, clemens = new Customer( ); twain = clemens; A B C A. Variables are allocated in memory. clemens twain B. The reference to the new object is assigned to clemens . Customer C. The reference in clemens is assigned to customer.
  • 20.
  • 21.
  • 23. Sample Code Fragment //code fragment to input radius and output //area and circumference double radius, area, circumference; radiusStr = JOptionPane.showInputDialog( null , "Enter radius: " ); radius = Double.parseDouble(radiusStr); //compute area and circumference area = PI * radius * radius; circumference = 2.0 * PI * radius; JOptionPane.showMessageDialog( null , "Given Radius: " + radius + "" + "Area: " + area + "" + "Circumference: " + circumference);
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33. Some Math Class Methods Table 3.8 page 113 in the textbook contains a list of class methods defined in the Math class. The sine of a . (Note: all trigonometric functions are computed in radians) sin(a) The square root of a . sqrt(a) The larger of a and b. max(a,b) Natural logarithm (base e ) of a . log(a) The number a raised to the power of b . pow(a,b) Natural number e raised to the power of a . exp(a) The largest whole number less than or equal to a . floor(a) Description Method
  • 34. Computing the Height of a Pole alphaRad = Math.toRadians ( alpha ) ; betaRad = Math.toRadians ( beta ) ; height = ( distance * Math.sin ( alphaRad ) * Math.sin ( betaRad ) ) / Math.sqrt ( Math.sin ( alphaRad + betaRad ) * Math.sin ( alphaRad - betaRad ) ) ;
  • 35.
  • 36.
  • 37. Sample Calendar Retrieval GregorianCalendar cal = new GregorianCalendar () ; //Assume today is Nov 9, 2003 System.out.print(“Today is ” + (cal.get(Calendar.MONTH)+1) + “/” + cal.get(Calendar.DATE) + “/” + cal.get(Calendar.YEAR)); Today is 11/9/2003 Output
  • 38.
  • 39.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.