You have put a lot of work in to manually building out a logic tree, and calculation system, to get the conversions right. Frankly, you have done so much of it by hand, that there's little left for the system to compute. Your determination is commendable. Addressing the mess first. A simple re- formatting of the code would do wonders for it. I took the liberty of using Eclipse, and running it through the auto- formatter: import java. Scanner. public class currency . Call it 'Currency'. Java is object oriented, which means you should actually have objects. You have none, and you embed all the logic in the constructor of the class.. Let's start with a currency convertion tool that is object oriented. The first object, is a currency, called Currency. Currency . The way to do it in this case is to have a common currency, and the exchange rates from all the other currencies to the common one. Since you list USD as the first currency, we will go with that, and the following table: USD. Euro 0. 7. 83. 91. GBP 0. 6. 21. 48. Now, we flesh out each currency to have the rate to the common currency: public class Currency . You can do it by dividing the exchange rates: Do some user input: double source. Amount = ..; // some source amount. String source. Currency = ..; // some currency. String target. Currency = ..; // you get the idea. This is a Java Swing GUI program for currency conversion. So basically here we convert one currency to other or vise versa. For detailed explanation of how swing works checkout my previous post; Java Swing GUI Here as usual we.Currency Converter - Two Classes; CONVERSION. A JavaScript Currency Conversion Script. Published November 28, 2011 by CSS Newbies. It turns out that converting random numbers into formatted currency (with dollar signs, commas, and periods) is more difficult in. Using Predefined Formats. The material that follows demonstrates formatting techniques with a sample program called NumberFormatDemo.java. For all your Java currency conversion needs. How to use our Java Currency Converter.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2016
Categories |