SlideShare uma empresa Scribd logo
1 de 71
Java Programming: From Problem Analysis to Program Design, 5e Chapter 3 Introduction to Objects and Input/Output
Chapter Objectives ,[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Chapter Objectives (continued) ,[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Object and Reference Variables ,[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
[object Object],[object Object],[object Object],[object Object],Object and Reference Variables (continued) Java Programming: From Problem Analysis to Program Design, 5e
Object and Reference Variables (continued) Java Programming: From Problem Analysis to Program Design, 5e
Object and Reference Variables (continued) Java Programming: From Problem Analysis to Program Design, 5e
Object and Reference Variables (continued) Java Programming: From Problem Analysis to Program Design, 5e
Java Programming: From Problem Analysis to Program Design, 5e ,[object Object],[object Object],[object Object],Objects and Reference Variables (continued)
Using Predefined Classes and Methods in a Program ,[object Object],[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Using Predefined Classes and Methods in a Program (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Using Predefined Classes and Methods in a Program (continued) ,[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
The  class  String ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
The  class  String  (continued) ,[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
The  class  String  (continued) ,[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Some Commonly Used String Methods Java Programming: From Problem Analysis to Program Design, 5e
Some Commonly Used String Methods (continued) Java Programming: From Problem Analysis to Program Design, 5e
Some Commonly Used String Methods (continued) Java Programming: From Problem Analysis to Program Design, 5e
Some Commonly Used String Methods (continued) Java Programming: From Problem Analysis to Program Design, 5e
Some Commonly Used String Methods (continued) Java Programming: From Problem Analysis to Program Design, 5e
Input/Output ,[object Object],[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Formatting Output with  printf ,[object Object],[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Formatting Output with  printf  (continued) ,[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Formatting Output with  printf  (continued) ,[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Formatting Output with  printf  (continued) ,[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Formatting Output with  printf  (continued) ,[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Formatting Output with  printf  (continued) ,[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Formatting Output with  printf  (continued) ,[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Formatting Output with  printf  (continued) Java Programming: From Problem Analysis to Program Design, 5e
Java Programming: From Problem Analysis to Program Design, 5e
Java Programming: From Problem Analysis to Program Design, 5e
Java Programming: From Problem Analysis to Program Design, 5e
Java Programming: From Problem Analysis to Program Design, 5e
Java Programming: From Problem Analysis to Program Design, 5e
Java Programming: From Problem Analysis to Program Design, 5e The output of these statements is:
Java Programming: From Problem Analysis to Program Design, 5e
Java Programming: From Problem Analysis to Program Design, 5e
Java Programming: From Problem Analysis to Program Design, 5e
Java Programming: From Problem Analysis to Program Design, 5e Sample Run: 123456789012345678901234567890 763  658.75 Java Program.  *** Java Program.  763  658.75  *** 658.75  763  Java Program.  *** num = 763  *** x = 658.75  *** str = Java Program.  *** Program No.4  ***
Parsing Numeric Strings Java Programming: From Problem Analysis to Program Design, 5e ,[object Object],[object Object],[object Object],[object Object],[object Object]
Parsing Numeric Strings (continued) Java Programming: From Problem Analysis to Program Design, 5e ,[object Object],[object Object],[object Object]
Parsing Numeric Strings (continued) ,[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Parsing Numeric Strings (continued) Java Programming: From Problem Analysis to Program Design, 5e ,[object Object],[object Object],[object Object]
Parsing Numeric Strings (continued) ,[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Using Dialog Boxes for Input/Output ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Using Dialog Boxes for Input/Output (continued) Java Programming: From Problem Analysis to Program Design, 5e
Parameters for the Method  showMessageDialog Java Programming: From Problem Analysis to Program Design, 5e
JOptionPane  Options for the Parameter  messageType Java Programming: From Problem Analysis to Program Design, 5e
JOptionPane  Example Java Programming: From Problem Analysis to Program Design, 5e
Formatting the Output Using the  String  Method  format ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
File Input/Output ,[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
File Input/Output (continued) ,[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
File Input/Output (continued) ,[object Object],Java Programming: From Problem Analysis to Program Design, 5e
File Input/Output (continued) Java Programming: From Problem Analysis to Program Design, 5e
File Input/Output (continued) Java Programming: From Problem Analysis to Program Design, 5e The statement in Line 1 assumes that the file prog.dat is in the same directory (subdirectory) as your program. However, if this is in a different directory (subdirectory), then you must specify the path where the file is located, along with the name of the file. For example, suppose that the file  prog.dat  is on a flash memory in drive  H . Then the statement in Line 1 should be modified as follows: Scanner inFile =  new  Scanner( new   FileReader("h:prog.dat")); Note that there are two   after  h: . Recall that in Java   is the escape character. Therefore, to produce a   within a string you need   . (Moreover, to be absolutely sure about specifying the source where the input file is stored, such as the flash memory in drive  h: , check your system’s documentation.)
File Input/Output (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
[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],File Input/Output (continued) Java Programming: From Problem Analysis to Program Design, 5e
Storing (Writing) Output to a File ,[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Storing (Writing) Output to a File (continued) ,[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Storing (Writing) Output to a File (continued) ,[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Storing (Writing) Output to a File (continued) ,[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
throws  Clause Java Programming: From Problem Analysis to Program Design, 5e ,[object Object],[object Object],[object Object],[object Object]
throws  Clause (continued) ,[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Skeleton of I/O Program Java Programming: From Problem Analysis to Program Design, 5e
Programming Example: Movie Ticket Sale and Donation to Charity ,[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Programming Example: Movie Ticket Sale and Donation to Charity (continued) ,[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Programming Example:  Student Grade ,[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Programming Example: Student Grade (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Chapter Summary ,[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Chapter Summary (continued) ,[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e
Chapter Summary (continued) ,[object Object],[object Object],[object Object],[object Object],Java Programming: From Problem Analysis to Program Design, 5e

Mais conteúdo relacionado

Mais procurados (15)

9781111530532 ppt ch09
9781111530532 ppt ch099781111530532 ppt ch09
9781111530532 ppt ch09
 
9781111530532 ppt ch11
9781111530532 ppt ch119781111530532 ppt ch11
9781111530532 ppt ch11
 
9781111530532 ppt ch01
9781111530532 ppt ch019781111530532 ppt ch01
9781111530532 ppt ch01
 
9781439035665 ppt ch07
9781439035665 ppt ch079781439035665 ppt ch07
9781439035665 ppt ch07
 
9781439035665 ppt ch02
9781439035665 ppt ch029781439035665 ppt ch02
9781439035665 ppt ch02
 
9781439035665 ppt ch04
9781439035665 ppt ch049781439035665 ppt ch04
9781439035665 ppt ch04
 
9781111530532 ppt ch10
9781111530532 ppt ch109781111530532 ppt ch10
9781111530532 ppt ch10
 
9781439035665 ppt ch05
9781439035665 ppt ch059781439035665 ppt ch05
9781439035665 ppt ch05
 
9781111530532 ppt ch05
9781111530532 ppt ch059781111530532 ppt ch05
9781111530532 ppt ch05
 
Chap04
Chap04Chap04
Chap04
 
Chapter 12
Chapter 12Chapter 12
Chapter 12
 
Pptchapter04
Pptchapter04Pptchapter04
Pptchapter04
 
Ppt chapter06
Ppt chapter06Ppt chapter06
Ppt chapter06
 
Ppt chapter10
Ppt chapter10Ppt chapter10
Ppt chapter10
 
9781111530532 ppt ch02
9781111530532 ppt ch029781111530532 ppt ch02
9781111530532 ppt ch02
 

Semelhante a 9781111530532 ppt ch03

9781439035665 ppt ch03
9781439035665 ppt ch039781439035665 ppt ch03
9781439035665 ppt ch03
Terry Yoast
 
9781111530532 ppt ch07
9781111530532 ppt ch079781111530532 ppt ch07
9781111530532 ppt ch07
Terry Yoast
 
9781111530532 ppt ch02
9781111530532 ppt ch029781111530532 ppt ch02
9781111530532 ppt ch02
Terry Yoast
 
9781111530532 ppt ch04
9781111530532 ppt ch049781111530532 ppt ch04
9781111530532 ppt ch04
Terry Yoast
 
9781439035665 ppt ch07_passing_primitivetypeasobjects
9781439035665 ppt ch07_passing_primitivetypeasobjects9781439035665 ppt ch07_passing_primitivetypeasobjects
9781439035665 ppt ch07_passing_primitivetypeasobjects
Terry Yoast
 
9781111530532 ppt ch07_passing_primitivetypeasobjects
9781111530532 ppt ch07_passing_primitivetypeasobjects9781111530532 ppt ch07_passing_primitivetypeasobjects
9781111530532 ppt ch07_passing_primitivetypeasobjects
Terry Yoast
 
9781111530532 ppt ch07_passing_primitivetypeasobjects
9781111530532 ppt ch07_passing_primitivetypeasobjects9781111530532 ppt ch07_passing_primitivetypeasobjects
9781111530532 ppt ch07_passing_primitivetypeasobjects
Terry Yoast
 
Basics of java 2
Basics of java 2Basics of java 2
Basics of java 2
Raghu nath
 
9781111530532 ppt ch05
9781111530532 ppt ch059781111530532 ppt ch05
9781111530532 ppt ch05
Terry Yoast
 
Question 1 1 pts Skip to question text.As part of a bank account.docx
Question 1 1 pts Skip to question text.As part of a bank account.docxQuestion 1 1 pts Skip to question text.As part of a bank account.docx
Question 1 1 pts Skip to question text.As part of a bank account.docx
amrit47
 

Semelhante a 9781111530532 ppt ch03 (20)

9781439035665 ppt ch03
9781439035665 ppt ch039781439035665 ppt ch03
9781439035665 ppt ch03
 
9781111530532 ppt ch07
9781111530532 ppt ch079781111530532 ppt ch07
9781111530532 ppt ch07
 
Chap03
Chap03Chap03
Chap03
 
Chap03
Chap03Chap03
Chap03
 
9781111530532 ppt ch02
9781111530532 ppt ch029781111530532 ppt ch02
9781111530532 ppt ch02
 
Chap02
Chap02Chap02
Chap02
 
9781111530532 ppt ch04
9781111530532 ppt ch049781111530532 ppt ch04
9781111530532 ppt ch04
 
Chap07
Chap07Chap07
Chap07
 
Full CSE 310 Unit 1 PPT.pptx for java language
Full CSE 310 Unit 1 PPT.pptx for java languageFull CSE 310 Unit 1 PPT.pptx for java language
Full CSE 310 Unit 1 PPT.pptx for java language
 
9781439035665 ppt ch07_passing_primitivetypeasobjects
9781439035665 ppt ch07_passing_primitivetypeasobjects9781439035665 ppt ch07_passing_primitivetypeasobjects
9781439035665 ppt ch07_passing_primitivetypeasobjects
 
9781111530532 ppt ch07_passing_primitivetypeasobjects
9781111530532 ppt ch07_passing_primitivetypeasobjects9781111530532 ppt ch07_passing_primitivetypeasobjects
9781111530532 ppt ch07_passing_primitivetypeasobjects
 
9781111530532 ppt ch07_passing_primitivetypeasobjects
9781111530532 ppt ch07_passing_primitivetypeasobjects9781111530532 ppt ch07_passing_primitivetypeasobjects
9781111530532 ppt ch07_passing_primitivetypeasobjects
 
Basics of java 2
Basics of java 2Basics of java 2
Basics of java 2
 
9781111530532 ppt ch05
9781111530532 ppt ch059781111530532 ppt ch05
9781111530532 ppt ch05
 
A Brief Overview of (Static) Program Query Languages
A Brief Overview of (Static) Program Query LanguagesA Brief Overview of (Static) Program Query Languages
A Brief Overview of (Static) Program Query Languages
 
java intro.pptx.pdf
java intro.pptx.pdfjava intro.pptx.pdf
java intro.pptx.pdf
 
JavaParser - A tool to generate, analyze and refactor Java code
JavaParser - A tool to generate, analyze and refactor Java codeJavaParser - A tool to generate, analyze and refactor Java code
JavaParser - A tool to generate, analyze and refactor Java code
 
Question 1 1 pts Skip to question text.As part of a bank account.docx
Question 1 1 pts Skip to question text.As part of a bank account.docxQuestion 1 1 pts Skip to question text.As part of a bank account.docx
Question 1 1 pts Skip to question text.As part of a bank account.docx
 
Chap13
Chap13Chap13
Chap13
 
Eo gaddis java_chapter_02_5e
Eo gaddis java_chapter_02_5eEo gaddis java_chapter_02_5e
Eo gaddis java_chapter_02_5e
 

Mais de Terry Yoast

Mais de Terry Yoast (20)

9781305078444 ppt ch12
9781305078444 ppt ch129781305078444 ppt ch12
9781305078444 ppt ch12
 
9781305078444 ppt ch11
9781305078444 ppt ch119781305078444 ppt ch11
9781305078444 ppt ch11
 
9781305078444 ppt ch10
9781305078444 ppt ch109781305078444 ppt ch10
9781305078444 ppt ch10
 
9781305078444 ppt ch09
9781305078444 ppt ch099781305078444 ppt ch09
9781305078444 ppt ch09
 
9781305078444 ppt ch08
9781305078444 ppt ch089781305078444 ppt ch08
9781305078444 ppt ch08
 
9781305078444 ppt ch07
9781305078444 ppt ch079781305078444 ppt ch07
9781305078444 ppt ch07
 
9781305078444 ppt ch06
9781305078444 ppt ch069781305078444 ppt ch06
9781305078444 ppt ch06
 
9781305078444 ppt ch05
9781305078444 ppt ch059781305078444 ppt ch05
9781305078444 ppt ch05
 
9781305078444 ppt ch04
9781305078444 ppt ch049781305078444 ppt ch04
9781305078444 ppt ch04
 
9781305078444 ppt ch03
9781305078444 ppt ch039781305078444 ppt ch03
9781305078444 ppt ch03
 
9781305078444 ppt ch02
9781305078444 ppt ch029781305078444 ppt ch02
9781305078444 ppt ch02
 
9781305078444 ppt ch01
9781305078444 ppt ch019781305078444 ppt ch01
9781305078444 ppt ch01
 
9781337102087 ppt ch13
9781337102087 ppt ch139781337102087 ppt ch13
9781337102087 ppt ch13
 
9781337102087 ppt ch18
9781337102087 ppt ch189781337102087 ppt ch18
9781337102087 ppt ch18
 
9781337102087 ppt ch17
9781337102087 ppt ch179781337102087 ppt ch17
9781337102087 ppt ch17
 
9781337102087 ppt ch16
9781337102087 ppt ch169781337102087 ppt ch16
9781337102087 ppt ch16
 
9781337102087 ppt ch15
9781337102087 ppt ch159781337102087 ppt ch15
9781337102087 ppt ch15
 
9781337102087 ppt ch14
9781337102087 ppt ch149781337102087 ppt ch14
9781337102087 ppt ch14
 
9781337102087 ppt ch12
9781337102087 ppt ch129781337102087 ppt ch12
9781337102087 ppt ch12
 
9781337102087 ppt ch11
9781337102087 ppt ch119781337102087 ppt ch11
9781337102087 ppt ch11
 

Último

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Último (20)

How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
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.
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 

9781111530532 ppt ch03

  • 1. Java Programming: From Problem Analysis to Program Design, 5e Chapter 3 Introduction to Objects and Input/Output
  • 2.
  • 3.
  • 4.
  • 5.
  • 6. Object and Reference Variables (continued) Java Programming: From Problem Analysis to Program Design, 5e
  • 7. Object and Reference Variables (continued) Java Programming: From Problem Analysis to Program Design, 5e
  • 8. Object and Reference Variables (continued) Java Programming: From Problem Analysis to Program Design, 5e
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16. Some Commonly Used String Methods Java Programming: From Problem Analysis to Program Design, 5e
  • 17. Some Commonly Used String Methods (continued) Java Programming: From Problem Analysis to Program Design, 5e
  • 18. Some Commonly Used String Methods (continued) Java Programming: From Problem Analysis to Program Design, 5e
  • 19. Some Commonly Used String Methods (continued) Java Programming: From Problem Analysis to Program Design, 5e
  • 20. Some Commonly Used String Methods (continued) Java Programming: From Problem Analysis to Program Design, 5e
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29. Formatting Output with printf (continued) Java Programming: From Problem Analysis to Program Design, 5e
  • 30. Java Programming: From Problem Analysis to Program Design, 5e
  • 31. Java Programming: From Problem Analysis to Program Design, 5e
  • 32. Java Programming: From Problem Analysis to Program Design, 5e
  • 33. Java Programming: From Problem Analysis to Program Design, 5e
  • 34. Java Programming: From Problem Analysis to Program Design, 5e
  • 35. Java Programming: From Problem Analysis to Program Design, 5e The output of these statements is:
  • 36. Java Programming: From Problem Analysis to Program Design, 5e
  • 37. Java Programming: From Problem Analysis to Program Design, 5e
  • 38. Java Programming: From Problem Analysis to Program Design, 5e
  • 39. Java Programming: From Problem Analysis to Program Design, 5e Sample Run: 123456789012345678901234567890 763 658.75 Java Program. *** Java Program. 763 658.75 *** 658.75 763 Java Program. *** num = 763 *** x = 658.75 *** str = Java Program. *** Program No.4 ***
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46. Using Dialog Boxes for Input/Output (continued) Java Programming: From Problem Analysis to Program Design, 5e
  • 47. Parameters for the Method showMessageDialog Java Programming: From Problem Analysis to Program Design, 5e
  • 48. JOptionPane Options for the Parameter messageType Java Programming: From Problem Analysis to Program Design, 5e
  • 49. JOptionPane Example Java Programming: From Problem Analysis to Program Design, 5e
  • 50.
  • 51.
  • 52.
  • 53.
  • 54. File Input/Output (continued) Java Programming: From Problem Analysis to Program Design, 5e
  • 55. File Input/Output (continued) Java Programming: From Problem Analysis to Program Design, 5e The statement in Line 1 assumes that the file prog.dat is in the same directory (subdirectory) as your program. However, if this is in a different directory (subdirectory), then you must specify the path where the file is located, along with the name of the file. For example, suppose that the file prog.dat is on a flash memory in drive H . Then the statement in Line 1 should be modified as follows: Scanner inFile = new Scanner( new FileReader("h:prog.dat")); Note that there are two after h: . Recall that in Java is the escape character. Therefore, to produce a within a string you need . (Moreover, to be absolutely sure about specifying the source where the input file is stored, such as the flash memory in drive h: , check your system’s documentation.)
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64. Skeleton of I/O Program Java Programming: From Problem Analysis to Program Design, 5e
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.