{"id":10514,"date":"2015-08-29T09:40:38","date_gmt":"2015-08-29T13:40:38","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/?p=10514"},"modified":"2015-08-24T10:33:26","modified_gmt":"2015-08-24T14:33:26","slug":"numformat-java-formats-real-numbers-with-decimalformat","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=10514","title":{"rendered":"NumFormat.java Formats real numbers with DecimalFormat."},"content":{"rendered":"<pre>import java.text.*;\r\n\r\n\/** Formatting real numbers with DecimalFormat.\r\n\u00a0*\r\n\u00a0*\u00a0 Taken from Core Web Programming from\r\n\u00a0*\u00a0 Prentice Hall and Sun Microsystems Press,\r\n\u00a0*\u00a0 .\r\n\u00a0*\u00a0 \u00a9 2001 Marty Hall and Larry Brown;\r\n\u00a0*\u00a0 may be freely used or adapted.\r\n\u00a0*\/\r\n\r\npublic class NumFormat {\r\n\u00a0 public static void main (String[] args) {\r\n\u00a0\u00a0\u00a0 DecimalFormat science = new DecimalFormat(\"0.000E0\");\r\n\u00a0\u00a0\u00a0 DecimalFormat plain = new DecimalFormat(\"0.0000\");\r\n\r\n\u00a0\u00a0\u00a0 for(double d=100.0; d&lt;140.0; d*=1.10) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(\"Scientific: \" + science.format(d) +\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \" and Plain: \" + plain.format(d));\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0 }\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>import java.text.*; \/** Formatting real numbers with DecimalFormat. \u00a0* \u00a0*\u00a0 Taken from Core Web Programming from \u00a0*\u00a0 Prentice Hall and Sun Microsystems Press, \u00a0*\u00a0 . \u00a0*\u00a0 \u00a9 2001 Marty Hall and Larry Brown; \u00a0*\u00a0 may be freely used or adapted. \u00a0*\/ public class NumFormat { \u00a0 public static void main (String[] args) { \u00a0\u00a0\u00a0 DecimalFormat &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=10514\">Continue reading<\/a><\/p>\n","protected":false},"author":130,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1417,1424],"tags":[706,308,285],"class_list":["post-10514","post","type-post","status-publish","format-standard","hentry","category-code-programming-samples--","category-javaj2eej2me","tag-code","tag-java","tag-285","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":26980,"url":"http:\/\/bangla.sitestree.com\/?p=26980","url_meta":{"origin":10514,"position":0},"title":"NumFormat.java Formats real numbers with DecimalFormat. #Programming Code Examples #Java\/J2EE\/J2ME #Basic Java","author":"Author-Check- Article-or-Video","date":"May 7, 2021","format":false,"excerpt":"import java.text.*; \/** Formatting real numbers with DecimalFormat. * * Taken from Core Web Programming from * Prentice Hall and Sun Microsystems Press, * . * \u00a9 2001 Marty Hall and Larry Brown; * may be freely used or adapted. *\/ public class NumFormat { public static void main (String[]\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10152,"url":"http:\/\/bangla.sitestree.com\/?p=10152","url_meta":{"origin":10514,"position":1},"title":"HelloWorld.java Simple servlet that generates plain text.","author":"","date":"August 14, 2015","format":false,"excerpt":"HelloWorld.java\u00a0 Simple servlet that generates plain text. import java.io.*; import javax.servlet.*; import javax.servlet.http.*; \/** Very simplistic servlet that generates plain text. \u00a0* \u00a0 \u00a0*\u00a0 Taken from Core Web Programming Java 2 Edition \u00a0*\u00a0 from Prentice Hall and Sun Microsystems Press, \u00a0*\u00a0 . \u00a0*\u00a0 May be freely used or adapted. \u00a0*\/\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26517,"url":"http:\/\/bangla.sitestree.com\/?p=26517","url_meta":{"origin":10514,"position":2},"title":"HelloWorld.java  Simple servlet that generates plain text. #Programming Code Examples #Java\/J2EE\/J2ME #Servlet","author":"Author-Check- Article-or-Video","date":"April 27, 2021","format":false,"excerpt":"HelloWorld.java Simple servlet that generates plain text. import java.io.*; import javax.servlet.*; import javax.servlet.http.*; \/** Very simplistic servlet that generates plain text. * * Taken from Core Web Programming Java 2 Edition * from Prentice Hall and Sun Microsystems Press, * . * May be freely used or adapted. *\/ public\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26844,"url":"http:\/\/bangla.sitestree.com\/?p=26844","url_meta":{"origin":10514,"position":3},"title":"EmployeeTest.java:  A test case for the database utilities. Prints results in plain text. #Programming Code Examples #Java\/J2EE\/J2ME #JDBC","author":"Author-Check- Article-or-Video","date":"May 3, 2021","format":false,"excerpt":"package cwp; import java.sql.*; \/** Connect to Oracle or Sybase and print \"employees\" table. * *\/ public class EmployeeTest { public static void main(String[] args) { if (args.length < 5) { printUsage(); return; } String vendorName = args[4]; int vendor = DriverUtilities.getVendor(vendorName); if (vendor == DriverUtilities.UNKNOWN) { printUsage(); return; }\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26956,"url":"http:\/\/bangla.sitestree.com\/?p=26956","url_meta":{"origin":10514,"position":4},"title":"Factorial.java Computes an exact factorial, n!, using a BigInteger #Programming Code Examples #Java\/J2EE\/J2ME #Basic Java","author":"Author-Check- Article-or-Video","date":"May 6, 2021","format":false,"excerpt":"import java.math.BigInteger; \/** Computes an exact factorial, using a BigInteger. * * Taken from Core Web Programming from * Prentice Hall and Sun Microsystems Press, * . * \u00a9 2001 Marty Hall and Larry Brown; * may be freely used or adapted. *\/ public class Factorial { public static void\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26585,"url":"http:\/\/bangla.sitestree.com\/?p=26585","url_meta":{"origin":10514,"position":5},"title":"TokTest.java  Illustrates parsing a string with a StringTokenizer. #Programming Code Examples #Java\/J2EE\/J2ME #Network Programming","author":"Author-Check- Article-or-Video","date":"April 29, 2021","format":false,"excerpt":"TokTest.java Illustrates parsing a string with a StringTokenizer. import java.util.StringTokenizer; \/** Prints the tokens resulting from treating the first * command-line argument as the string to be tokenized * and the second as the delimiter set. * * Taken from Core Web Programming from * Prentice Hall and Sun Microsystems\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/10514","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/130"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10514"}],"version-history":[{"count":2,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/10514\/revisions"}],"predecessor-version":[{"id":10516,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/10514\/revisions\/10516"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10514"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10514"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10514"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}