Software Development Assignment – Java

We were set an assignment at college to create a program in Java using IntelliJ.

The assignment criteria was to create a currency converter that converts GBP into 3 different currencies where the end user can manually input the exchange rates.

The challenge set by the tutor (for a clear distinction) was to add an extra feature so that when you click a button it will pull the latest exchange rates from the internet.

As I am stubborn and not one to back down from a challenge, it was one I was willing to accept.

The user interface was quite difficult to create with IntelliJ and all the tutorials online showed that people were typically using NetBeans which I downloaded and found it so much easier to create a user interface as it was just drag and drop rather than worrying about spacing.

I created an action listener so that when the appropriate buttons were created they would act upon the code I had set to each button click. So the clear button would default the text field back to its original state using a jbutton.setText(“1”); I used an action listener for each button.

The currency exchange button turned the input number from a string to a float variable and then I calculated one float by another, example: GBP*EUR and then converted the float back into a string to output it into the area to show the amount.

For the auto generate section of the program, I used JSON (JavaScript Object Notation) and set the URL from Yahoo Finance as a string but added a variable called currency in the middle of the URL so that it would change the variable fromto section so that when you click on the auto generate button next to the Euro it would change the variable to GBPEUR and pull the latest Euro rate, when you click on the auto generate next to the US Dollar it would change the variable value to GBPUSD and pull the US Dollar rate and the same again with the Chinese Yuan.

You will need to download Java Runtime Environment to run this .jar executable file but please feel free to download and play around with my program. Download can be found here: Java Currency Converter

I have also added the code in a text file in case anyone would like to have a go. Download code

Share Button

Leave a Reply

Your email address will not be published.