![]() Each method should Do One Thing and Do It Well™ (Palm Corporation, I think). You could break your current main method into a read-data method, a compute method(s) and output method and have the 3 of them be invoked serially (and repeatedly) by doIt(). In truth, any method that runs more than about 20 lines of code is suspect. And it's simple to tack on small snippets to the main code for extensions, debugging, general setup calls and so forth. The virtue here is that main() is always very simple. * Main processing logic for currency converter. ![]() Creates a converter instance and invokes it.įinal Currenc圜onverter cc = new Currenc圜onverter() * Interactive app to convert to/from Malaysian currency. Like if you have 100,000 class instances containing floating-point values and you only need 6.5-digit precision anyway.Ĭampbell Ritchie wrote:Don't write long methods the ideal length of the main() method is one statement. Might as well save the effort, except in cases where storage use is critical. And once upscaled, you can get yelled at by the compiler for attempting to assign those fatter values to skinnier variables. Any work with lesser-sized values will fold up into those forms unless you stringently avoid it. Integer and double are the "natural" data types for Java. ("Your " + amount + " Dollar is : " + f.format(ringgit) + " ringgit") Ĭampbell Ritchie wrote: My opinion is, don't use floats at all, unless some other code requires you to. ("How much Money you want to convert ?") ("Which currency You want to Convert ? ") Converts a given amount in the US Dollar into an equivalent ringgit amountĭecimalFormat f = new sc = new Scanner(System.in) Converts a given amount in ringgit into an equivalent amount in US Dollar Exchange rate to convert a US Dollar to ringgitĬonstructor: to set the initial value for the attribute ![]() ![]() How do modify the code to use the attribute from the details below? Thank you I got a code from the forum but it is not using the same attribute. I need assistance with the following project which seems very complicated. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |