Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please follow this pseudocode to code line to line exactly what it says for this assignment in Java! Instructions are below and please write comments.
Please follow this pseudocode to code line to line exactly what it says for this assignment in Java! Instructions are below and please write comments.
-
create File object for currencies.txt create scanner1 to read from input file create new DefaultCategoryDataset object to contain bars for histogram while more lines in input file read target currency using scanner1 construct URL for obtaining target exchange rate create scanner2 from URL use URL to obtain JSON string extract target exchange rate from JSON string add histogram bar representing target exchange rate to DefaultCategoryDataset object close scanner2 end while create a bar chart object from DefaultCategoryDataset object create graphics image file close scanner1
- As you are working on this project, add print statements or use the debugger to help you verify what is happening. Write and test the project one line at a time.
- Before you try to obtain currency exchange rates, obtain your free 32 character access code from this website:
https://fixer.io/ Here's the code: 46f27e9668fcdde486f016eee24c554c
- Choose five international source currencies to monitor. Each currency is referenced with a three letter ISO 4217 currency code. For example, the code for the British Pounds is GBP. " Place these currency codes in a text file named currency.txt.
- Use these codes: Colombian Peso: COP: 3540 .250862, Costa Rican Colon CRC: 685.938731, Egyptian Pound EGP: 19.758935, Jamaican Dollar JMD: 150.549578, and Yen JPY: 124.536082 place them in a file called currency.text
- Use try..catch blocks to handle all exceptions with a user-friendly messages in the catch blocks. Do not throw any exceptions.
- In a while loop that terminates when the end of file is reached, do the following:
- Read the next currency from the currencies.txt file.
- Create a URL for the fixer.io site that will obtain a URL for obtaining the exchange rate using the currency read in Step 1 as the target currency (symbol) and EUR as the source currency (base).Which you code:
http://data.fixer.io/api/latest
? access_key = 46f27e9668fcdde486f016eee24c554c or YOUR_ACCESS_KEY instead of the code itself, one of them should work
& symbols = COP,CRC,EGP,JMD,JPY
- Using the URL from Step 2, create a scanner object that reads the JSON string from the website. Extract the exchange rate from the JSON string.
- Add a bar to a JFreeChart bar chart, whose height is the exchange rate from Step 3.
Identify the source code items that belong before, in, and after the while loop
- Don't forget to close each scanner when you are finished using it.
- Your project should contain only a single class, which contains the main method. This class must define at least three additional static methods that modularize the tasks in this project. For example, you might define methods such as these:
public static String getCurrency(Scanner s) public static String getUrlString(String targetCurrency) public static double getExchangeRate(String urlString)
-
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started