![]() |
|
#1
|
|||
|
|||
Code for HomeworkI have written a code for a homework assignment and would like someone to look at it and seif it is okay, it compiles and answers the questions of what the interest for the life of the loan and the number of months the repay is, but for some reason I cannot get the interest payments to be with only 2 decimals, they have several trailing numbers after the decimal.
JAVA Code:
Can some one advise me? Thanks Barb Last edited by admin II : 27-Feb-2007 at 06:42.
Reason: Please surround your Java code with [java] ... [/java]
|
|||
|
#2
|
|||
|
|||
Re: Code for HomeworkSuggestions (These are only suggestions based on my own experience, YMMV, no warranty, no claim of fitness for any particular purpose, void where prohibited by law, no animals were harmed in the making of these suggestions with the possible exception of that dog next door who barks incessantly and deserves to be shot):
- In Java, use objects instead of base types. That is, prefer to use Double instead of double. - When dealing with money, prefer BigDecimal to Double. The reason is, BigDecimal is "arbitrary precision", has eight user-selectable rounding modes, etc. etc. Check it out... http://java.sun.com/j2se/1.5.0/docs/...igDecimal.html |
|
#3
|
||||
|
||||
Re: Code for HomeworkYou need a 'formatter'.
Maybe the NumberFormat class, perhaps? JAVA Code:
JAVA Code:
JAVA Code:
__________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
Recent GIDBlog
New Corolla Altis, 10th Generation - Part I by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to sort random access file? | wmmccoy0910 | C Programming Language | 12 | 04-Sep-2006 03:40 |
| 25-35% off on all shared & reseller packages FOR LIFE! | my-e-space | Web Hosting Advertisements & Offers | 0 | 11-May-2006 21:00 |
| Here it is again! 35% - 40% off For Life! | my-e-space | Web Hosting Advertisements & Offers | 0 | 20-Apr-2006 14:48 |
| functions seems not to exit from a certain code block | jaro | C Programming Language | 3 | 21-Mar-2006 23:08 |
| Problem with int mixed with char,... | leitz | CPP / C++ Forum | 17 | 07-Dec-2004 20:56 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The