Upload
others
View
18
Download
0
Embed Size (px)
Citation preview
Java Gently for Engineers and Scientists
Judith M Bishop Department of Computer Science University of Pretoria
Nigel T Bishop Department of Mathematics, Applied Mathematics and Astronomy University of South Africa
An imprint of Pearson Education Harlow, England • London • New York • Reading, Massachusetts • San Francisco Toronto • Don Mills, Ontario • Sydney • Tokyo • Singapore • Hong Kong • Seoul Taipei • Cape Town • Madrid • Mexico City • Amsterdam • Munich • Paris • Milan
Contents
Chapter 1
Chapter 2
Chapter 3
Example programs and Case studies Preface
Introduction
1.1 Welcome to Java 1.2 Software development 1.3 Scientific Computing 1.4 Getting started with Java 1.5 The web site Quiz
Simple programs 2.1 Two Starter programs 2.2 Java basics 2.3 Beginning with Output 2.4 Expressions and assignment 2.5 Numerical Computing Quiz Problems
Structuring 3.1 Properties of a good program 3.2 Repetition with for-loops 3.3 Input and Output on a display 3.4 Making methods 3.5 The Graph class 3.6 Numerical methods with for-loops Quiz Problems
xi xiii
1 1 5 9
13 17 17
19 19 22 27 30 37 48 49
51 51 53 62 68 77 81 94 95
viii Contents
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Controlling 4.1 Files for input and Output 4.2 The types b o o l e a n and c h a r 4.3 Selection with i f - e 1 s e and swi t c h 4.4 Conditional loops with whi 1 e and do 4.5 Handling exceptions 4.6 Arithmetic accuracy 4.7 Numerical methods with while-loops Quiz Problems
Arrays and matrices 5.1 Simple arrays 5.2 Matrices 5.3 Numerical methods - linear curve fitting 5.4 Numerical methods - solving linear equations 5.5 Case study 1: Linear boundary value problem Quiz Problems
Abstraction 6.1 Class power 6.2 Class-independent tables 6.3 Abstract methods and classes 6.4 Working within a hierarchy 6.5 Numerical methods with abstraction 6.6 Case study 2: Process control Quiz Problems
Customizing 7.1 Introduction to the awt 7.2 Laying out a GUI 7.3 Events, listeners and handlers 7.4 Inside the Graph class
99 99
106 111 116 121 126 133 138 139
143 143 156 161 167 175 181 182
185 185 190 196 206 216 231 238 239
243 243 253 261 267
Chapter 8
Chapter 9
/
Quiz Problems
Networking 8.1 From applications to applets 8.2 Connecting via the Internet 8.3 Sound and images 8.4 Animation through threads 8.5 Case study 3: The Planets Project Quiz Problems
Distributing 9.1 Formalities of threads 9.2 Inside the D i s p l a y class 9.3 Ports and sockets 9.4 Case study 4: The chatter System 9.5 Case Study 5: The nuclear reactor Quiz Problems
Chapter 10 Additional topics
Answers to
10.1 Strings and string handling 10.2 Inside the Tex t class
Contents ix
278 278
281 281 290 295 300 311 323 324
325 325 332 339 345 350 368 369
371 371 376
10.3 Formatting with the j a v a . t e x t package 382 10.4 Dates, calendars and times 10.5 Lists of objects 10.6 Other object properties 10.7 Interfaces for generality Quiz Problems
quizzes
387 392 398 401 409 409
413
Index 422