Next:
Introduction
Contents
RHUL Department of Physics
PH2150 Scientific Computing Skills
Java Programmming
S. George and C. V. Quarman
Autumn Term 2011
Introduction
Objectives
Assessment
1 Programming Basics
Computer programs and java
Basic program structure
Running a program on a lab PC
Writing
Saving
Compilation
Running
Comments
Variables -- declaring and assigning values
Simple output
Arithmetic operators
2 Input, mathematical functions and conditional branching
Keyboard input
Mathematical library
The
if
statement and comparison operators
Else and else if
Logical operators
3 Iteration
For loops
While loops
Flow control
Scope
4 Arrays, nested loops and composite operators
Creating an array
Array manipulation and references
Composite operators
Multi-dimensional arrays and nested loops
5 More advanced input and output
Formatting output
Input from a file
Output to a file
6 Multiple methods
Basics of using another method
Passing information between methods
Other information about methods
Method naming
Class variables, method variables and scope
Passing arrays to methods
7 Numerical problems and multiple classes
Numerical integration
Multiple classes
8 Object oriented programming
Introduction to object orientation (OO)
Creating an object
Non-static methods
Constructor methods
Using private class variables
Discussion of objects and static vs. non-static methods
Closing remark
9 Statistics exercise using external software
Random number generator
Making histograms
Drawing graphs
Compiling and running with PtPlot
Final exercise
Bibliography
Appendices
A. How to use Java on the PC lab computers
Instructions
MSDOS tips
Directories
Screen size
Editing on the command-line
Cut and paste
Redirecting program output to a file
Installing Java
Installing Jext
B. Dealing with errors
Compile-time errors
Run-time errors
C. Trapezium rule for integration
Trapezium rule
Extended trapezium rule
Programming
Pitfalls
Code
Method
D. Histograms
About this document
RHUL Dept. of Physics