Current course
Participants
Topic outline
Introduction
Java is a programming language originally developed by Sun Microsystems and released in 1995 as a core component of Sun Microsystems’ Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of computer architecture. Taken from WikipediaIf you are working via the console then you compile programs using the javac tool and then execute with java. The class and file must be using the same name. Do not need to include .class file extension when executing. However you will probably want to use an IDE like Netbeans or Eclipse.
Not to be confused with Javascript which although very similar and sharing some syntax is not the same – although if you can write java you can probably write Javascript!
Case Conversion
Take a string given at the command line and convert to one of the following depending upon the option given:- -u = uppercase
- -l = lowercase
- -t = titlecase
Very high likelihood that the titlecase conversion could be improved upon. Recollection that there is now a
string.Titlecase()function.Factorials
The following program demonstrates the use of Java to make a simple factorials program. This example is made increasingly complicated by the use of Big Integers to allow for larger numbers.Polish Notation Calculator
A rather old implementation of a Polish Notation calculator (circa 2000) in Java.It reports notes regarding unsafe operations which are probably a consequence of its age and thus it could probably do with some streamlining.
Triangles
The following program calculates the type of triangle depending upon the three sides given at the command line. At my initial attempt to solve this simple issue (circa 2000) I completely failed to see the full extent of the problem and thus achieved a rather miserable 2/5 for this program. Hopefully this revised version (2012) is more impressive – that said my testing will be minimal so if you dare to test it please let me know if any cases fail to deliver the correct answer.The problem statement was:
The problem is to read in three integers representing the lengths of the sides of a triangle, and to print out a description of what kind of triangle it is. There are three main requirements. The first is to produce a Haskell program and a Java program which are suitable for being semi-automatically compiled, run and tested by the marker. The second is to print out accurate descriptions for numbers which are typed in. The third is to deal with all possible ways in which a user might misuse your program, producing sensible error messages in all cases.
Topic 5