Java
In this section are links to all the programs that I wrote using the high level programming language of Java and a program using JavaCC. The first selection comprises of code which I wrote and compiled within the first year of study at university and the last remaining program being created in the second year.
How to install JDK runtime and run java programs in the command line.
Step 0: Test if java is installed
Alternatively, open a command prompt window (press Win⊞ + R, type cmd, and hit Enter) and enter the command: java -version. This will output the version of Java installed on your computer. If the command is not recognized then you will need to install tg Java SDK
Step 1: Install Java SDK
Step 2: Find path to your Java installation folder which can be found through
Environment variables for java installation
File Explorer or Command Prompt. This will usually be C:\Program Files\Java\
Step 3 Right Click on MyComputer and click on properties .
Step 4: Click on Advanced tab
Step 5: Click on Environment Variables
Step 6: Create a new class path for JAVA_HOME
Step 7: Enter the Variable name as JAVA_HOME and the value to your jdk bin path ie c:\Programfiles\Java\jdk-1.6\bin and
NOTE Make sure u start with .; in the Value so that it doesn't corrupt the other environment variables which is already set.
Step 8 : Follow the Above step and edit the Path in System Variables add the following ;c:\Programfiles\Java\jdk-1.6\bin in the value column.
Step 9 :Your are done setting up your environment variables for your Java , In order to test it go to command prompt and type
java
who will get a list of help doc
In order make sure whether compiler is setup Type in cmd
javac
who will get a list related to javac
To run a program type
go to the directory where the program is installed:
cd
Then type in:
java file.java
How to compile & run a Java application
Programs
Cookie Recipe Ingrediants Calculator
This program calculates the amount of ingredients required to make a define number of cookies.
Investment Program
This program was created as simple way to calculate interest on a given amount of money. To test my skill and development of variable names, use of operators and expressions.
Mileage Program
This program displays the efficiency of the vehicle in kilometres of the vehicle in kilometres per gallon to an accuracy of 2.d.p. The distance travelled per litre of petrol to the nearest meter and the cost of driving 100 kilometres using the computers current locale to display the correct currency.
Magic Number Program
The aim of this program is for the user to guess the number between 1 and 10 that the computer has randomly generted. The computer generates the number, then allows the user to guess three times. After each turn the computer informs the user if the guess is too high or too low. The user wins if they guess the correct number. At the end of the game the program will ask if the user would like to replay the game.
Cartesian Transformation Program
This program is able to calculate new sets of coordinates on a Cartesian grid when some type of transformations is used upon them. It also reinforces understanding in the implementation of classes, methods, object and instance variables.
Pontoon Program
This program runs a version of pontoon or black jack using the command-line function in Java. The aim of the game is to gain a higher sum then the bank but without being higher then the value of 21. The bank deals a hand of two cards, the player then inspects these cards and then chooses whether to stick or twist in which case the player receives another card. This continues until the player decides to stick achieves a five card trick or goes bust. The bank then deals itself a card until it has a value greater than or equal to that of the players or goes bust in which case the player wins.
SVGDraw Program
This program imitates a selection of different images using JavaCC and SVGDraw.
SVG DRAW
P0Test
Example | Output |
---|---|
P1Test
Example | Output |
---|---|
P2Test
Example | Output |
---|---|
P3Test
Example | Output |
---|---|
P1Juggle
Example | Output |
---|---|
P2Juggle
Example | Output |
---|---|
Correlation Calculation Program
This program takes a dataset and calculates the Variance of X and Y, Covariance and Correlation.
Collapsing Puzzle Game
A game of levels where the player aims to clear all the blocks in the grid, or runs out new lines that need to be injected into the grid.