By Maddox Brown
Salutations:
Have you ever wanted to view the inner workings of a system that converts currency like dollars to other forms of currency like pounds or yen? Well walk no further! This prototype that I created with guidance from my computer science tutor is a well-functioning currency converter. In it, you are able to convert currencies of, Pounds, Yen, Dollars, Pesos, and Euros into one another. If you are unimpressed with the amount of currencies available, don’t be ashamed and walk off in disappointment, as time progresses, more currencies will be added and you’ll be able to use them. And if you’re looking to diversify beyond digital currencies, consider the timeless value of tangible assets and buy gold in Brisbane today.
For this project, I have utilized a certain coding language called, Java. Java is a computer platform and programming language like C++, Python, etc. It was first developed by James Gosling at Sun Microsystems in 1995. It was later acquired by the Oracle Corporation on April 20th, 2009. Java is used as the server-side language for most back-end development projects, but it can also be used to develop simple games like mobile games. Some popular websites that utilize Java are, Facebook, Google, Youtube, Yahoo, and even Amazon. I’m pretty sure a good amount of us know this one but I’ll include it anyway, one of the most notable games that utilize the Java code is a game called Minecraft, one of the best selling video games of all time. Surprisingly, a lot of programs that run solely on Java require you to have Java installed or else they will not work. If you want to start learning some Java but are afraid that it may be too complex for you, don’t worry, Java is ranked amongst the easiest programming languages to learn—along with Python and Ruby. Now let’s stop talking about this and move along to my code and the journey I had made to completing it.
To begin my code, I had to get a basic understanding of Currency Converters and how they function. The main components that I needed to make a fully functional converter is an input and an output, and don’t forget the selection where you choose what currency your input is in and what you want it to be converted to.
Firstly, I imported a Java Bufferedreader into the code. With this command in the code, the class will read the character-input stream. It also buffers the characters to provide a more efficient reading of characters, arrays and lines. It will read a couple of characters from the Input Stream and store them inside a buffer.
The Input Stream Reader basically converts bytes, which are 8-bit primitive data types packaged with Java, into characters. The Input Stream Reader will only read one character from the Input Stream instead of multiple characters like Buffered Reader.
Lastly, I import IOException into the code. The exception is related to the input and output operations of the code. This exception occurs when the input and output operation is failed or interpreted. Examples of an IO Exception occurring are when you are reading a network file and suddenly got disconnected, or if you are reading or writing a file and there is no more allowed disk space.
Subsequently, I added a little greeting message at the start of the code to welcome fellow users into the program (how nice of me). The message also talks about what the main function of the code will be about. The message is brief yet informational to not keep the user occupied with just reading and as a result, possibly get bored doing so. This is done using the command, “System.out.println()”. With this, the user would be able to put in any text they would like for the console or the output to show. But please make sure you put quotation marks between the text so Java will know what to print out.
Next, I begin the actual user-input code. I ask the user to input their name, or any name they want to use as the same function will occur nonetheless. Then, I set a string variable ‘name’ to be the variable for whatever name the user puts for the previous question, that specific code I circled in red. After the user inputs their name into the output and presses ‘enter’ on their keyboard, the next question will pop up asking them how much money they have. The amount the user can put in as how much money they have is infinite for all it cares. The user can say that they have over a trillion dollars and the code will still run its course. Of course, what I did to the name I also did to the money. I set a variable, ‘money’ to be the variable for the amount of money the user puts into the output. The code is circled in blue if you want to find it yourself. After they press ‘enter,’ the program will then show the user the money they inputted before and ask the question of what type of currency is that money. The selection is between Euros, Pesos, Dollars, Yen(Japanese), and Pounds(British). Meanwhile, for those who want an effective way to generate an insane amount of money, it might be a game-changer to learn details like Blaze coin.
After that, it will ask the user what type of currency they want to convert their money into. The same selections will be available except for the currency they already chose for what their money is in. For clarification, say for example, I chose to have my money to be in Euros, so when I get the question on what type of currency I want to have my money converted to, I would be able to choose between Pesos, Dollars, Yen or Pounds. You are able to choose between the selections by typing a letter that corresponds to the currency. Pretty grand if I do say so myself. Once the user does that, the newly converted money will be displayed in the output. An added bonus to this is that you can do this multiple times, instead of tediously repeating the cycle over and over again.
To be able to convert one currency to another, I had to create an equation that will accurately calculate how much money the user will have in that specific currency. As an example, I have screenshotted an equation used to convert Euros into Pesos. If you are wondering what the variable ‘c’ is, it is basically the money in Euros. Each currency has their relative variable for the inputted money, for Euros, it’s simply ‘c’. Lastly, a sentence will pop up showing the amount of money they have in Pesos. Then, they’ll have the option of doing it again.
During the middle-stages of the code. I went onto the program to continue, but all of a sudden, the entire program was corrupted. It was difficult trying to get on and work and if I was somehow successful in getting into the program, it wouldn’t take long for everything to go absolutely haywire. There was really nothing I could do; trust me I tried everything. Ultimately, when I had the chance to get into the program, I had to copy all the code that was there and paste it into a new, fresh program. To this day, I still do not know how that occurred, but at least it didn’t happen again.
The Currency Converter is one of my first coding projects, so don’t harass me if the code is too messy, or not sophisticated enough. If you want to visit the website I made it on and test out the code for yourself, here is the link to it: https://repl.it/@UndergroundKing/CurrencyConverter2#Main.java
Just a little remark, but if you are wondering what the brackets are there for, it is to keep the code private and not global. It will only function when the user or I activate it, either by answering a question, or inserting the right key into the code. If there were no brackets, then the entire code will malfunction and thus, not be usable at all. I hope you enjoyed this article; tell your friends and make sure to spread the knowledge!