Results 1 to 2 of 2
Thread: Need help rounding. =/
- 10-07-2008, 04:51 AM #1
Member
- Join Date
- Oct 2008
- Posts
- 1
- Rep Power
- 0
Need help rounding. =/
This is my current code.
How can I make it so the output is rounded to two decimal places?Java Code:import javax.swing.JOptionPane; public class TwoDecimalPlaces { public static void main (String[] args) { String outputStr; String inputStr; float x; inputStr = JOptionPane.showInputDialog ("Enter the number you would like rounded to two decimal places"); x = Float.parseFloat(inputStr); outputStr = "Rounded to two Decimal Places: " + x + "\n"; JOptionPane.showMessageDialog(null, outputStr, "Rounding Numbers:", OptionPane.INFORMATION_MESSAGE); System.exit(0); } }
I tried google searching with no luck... and I am still kind of new so the API is rather confusing to me still, lol.
Thanks for any help!
-
Similar Threads
-
rounding double to two decimal places
By javaMike in forum Advanced JavaReplies: 15Last Post: 03-10-2010, 12:04 AM -
Help with java Rounding
By silvia in forum New To JavaReplies: 1Last Post: 07-20-2007, 07:25 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks