After some awesome help yesterday on this site, I am back with another question. I have my input/output equation the way I want it but need help rounding the decimal off to the hundredths position. The way it is set up now the output of pounds seems to just repeat the answer. I have been inputting 10.2 as the weight in kilograms and the answer I keep receiving in pounds is 22.4422.44. I know it is something with the String.format I am using but after messing with it for quite a while I can't seem to figure it out. I know it is something silly but I have been working on this for a while now and I think my brain may be mush. Below is my program.  //This program converts kilograms to pounds using input/output dialog boxes.  import javax.swing.*;  public class SNHU2_3 {      public static void main (String[] args){          String inputStr;         String outputStr;           double pounds;         double kilograms;           inputStr = JOptionPane.showInputDialog("Enter weight in kilograms");         kilograms = Double.parseDouble(inputStr);          outputStr = ("Kilograms = " + kilograms) + "\n" + ("Pounds = " +  (kilograms * 2.2)) + String.format("%.2f", (kilograms * 2.2));          JOptionPane.showMessageDialog(null, outputStr, "Weight Conversion", JOptionPane.INFORMATION_MESSAGE);         System.exit(0);       } }
What I would like is a method to convert a double to a string which rounds using the half-up method - i.e. if the decimal to be rounded is 5, it always rounds up to the next number. This is the standard method of rounding most people expect in most situations.  I also would like only significant digits to be displayed - i.e. there should not be any trailing zeroes.  I know one method of doing this is to use the String.format method:  String.format("%.5g%n", 0.912385);   returns:  0.91239   which is great, however it always displays numbers with 5 decimal places even if they are not significant:   String.format("%.5g%n", 0.912300);   returns:  0.91230   Another method is to use the DecimalFormatter:  DecimalFormat df = new DecimalFormat("#.#####"); df.format(0.912385);   returns:  0.91238   However as you can see this uses half-even rounding. That is it will round down if the previous digit is even. What I'd like is this:  0.912385 -&gt; 0.91239 0.912300 -&gt; 0.9123   What is the best way to achieve this in Java?
What are the downsides of removing ubuntu-desktop metapackage? Inequality: $x^2+y^2+xy\ge 0$ I want to prove that $x^2+y^2+xy\ge 0$ for all $x,y\in \mathbb{R}$.  My "proof":  Suppose wlog that $x\ge y$, so $x^2\cdot x\ge x^2\cdot y\ge y^2\cdot y=y^3$ (because $x^2\ge 0$ so we can multiply both sides by it without changing the inequality sign) giving $x^3\ge y^3$. Substracting we have $x^3-y^3\ge 0$ or $(x-y)(x^2+xy+y^2)\ge 0$. Since $x\ge y$ we can divide by $x-y$ to get $x^2+xy+y^2\ge 0$.  Is it right?  Thanks for your help! How to handle fragmentation of auto_increment ID column in MySQL I have 24 accounts, how can I delete them all in one go? Is there a way to delete all stack exchange accounts at the same time?  I also want to remove all traces of my posts on the site. Is that possible?   Will I have to delete all of my posts manually?  Can I use the stack exchange API for this? Compiler error C3493: 'func' cannot be implicitly captured because no default capture mode has been specified How should I setup separate MX records for a subdomain? "1 out of 100 chickens is" or "1 out of 100 chickens are"? Downgrading from Safari 12 (beta) to Safari 11 Installing Safari beta version is apparently only possible by replacing the builtin Safari version. In this case version 11.1.2 with 12. If beta version does not work, gives too much trouble or is just unpleasant:  How do we downgrade to an official stable version, currently Safari 11.1.2 for 10.12.6 Sierra?  I tried to restore everything relating to 11.1.2 from a backup (going by what is found that is in the installer package), I located and re-applied the 11.1.2_Sierra.pkg. Yet Safari now refuses to work entirely.   Crashed Thread:        3  Dispatch queue: com.apple.SafariCore.RemotePlistController.internalQueue  Exception Type:        EXC_CRASH (SIGABRT) Exception Codes:       0x0000000000000000, 0x0000000000000000 Exception Note:        EXC_CORPSE_NOTIFY  Application Specific Information: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[_NSPlaceholderData initWithContentsOfURL:options:error:]: nil URL argument' terminating with uncaught exception of type NSException abort() called   Is there any way around re-installing the entire system? I would like to protect myself from unreasonable demands during my work day.  One of those is telling people that I will not respond to any emails before 3pm.  I'd like to set up a rule in outlook that replies to all emails before 3pm with a specific message. I'd like this to be done every day, no matter the date.  How do I set this up?  I've scoured Google best I can so far, and I think, based on a Exchange forum, that a script might be needed for this.  But what I found so far was only server side scripts. I need something on my own machine.  references: Is Dragonstone unoccupied after Stannis Baratheon's defeat? Is anything known about Dragonstone after:      Stannis Baratheon is killed in his bid for the Iron Throne?   As the seat of the naval defense of King's Landing and the birthplace of Daenerys Targaryen, she has a vested interest in taking it.   At the conclusion of Season 6 Episode 10, is Dragonstone unoccupied? Keyboard shortcut to minimize a window on Ubuntu 18.10 Festival stores voicepack data in the following example directory structure:  /usr/share/festival/voices/&lt;language&gt;/&lt;voicepack name&gt;  What is the simplest one-liner (preferably using ls) to print out just the &lt;voicepack name&gt;'s, in all the potentially numerous &lt;language&gt; subdirectories? How to connect to my web server? I have implemented a simple web server as a solution to a course assignment and I want to connect to this web server over the internet. I've set it up to listen on port 22881 and configured my router accordingly as the screenshot below shows    I'm able to connect to my web server locally using http://localhost:22881 and I can connect to the router's interface when I visit http://my.external.ip, but I can't connect to my web server using http://my.external.ip:22881 (I get a connection timeout). Any idea of what may be the problem?  Thanks in advance! Isometries of the sphere $\mathbb{S}^{n}$ Got this as homework and I don't know how to tackle this. Help please!  Prove that the isometries of $\mathbb{S}^{n} \subset \mathbb{R}^{n+1}$, with the induced metric, are restrictions to $\mathbb{S}^{n}$ of the linear orthogonal transformations. The question is:     Are there square matrices $A,B$ over $\mathbb{C}$ s.t. $A^2+B^2=AB$ and $BA-AB$ is non-singular?   From $A^2+B^2=AB$ one could obtain $A^3+B^3=0$. Can we get something from this?  Edit:  $$A^2+B^2=AB\implies\\ A(A^2+B^2)=A^2B \implies\\ A^3+AB^2=A^2B \implies \\ A^3+(A^2+B^2)B=A^2B \implies \\  A^3+A^2B+B^3=A^2B \implies \\ A^3+B^3=0 $$ Where can I start to learn ArcPy? In newer Google Maps I can make area available offline.  Do other applications that rely on Google Maps (utilize Google Maps Android API) use offline maps? E: dpkg was interrupted... run 'sudo dpkg --configure -a' I was running an upgrade with the apt-get command, and it was taking an exceptionally long time because half way through my ISP hit me in the face with their fair usage policy.   After sitting outside &amp; watching the rain for awhile my electronics regained consciousness, so I went back to complete the upgrade and my terminal scolds me with   "E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem."   The last bit of legible info was all this:  Installing (ri/RDoc) documention for (stuff and such) ERROR:  Could not find a valid gem 'watobo-0.9.8.724.gem' (&gt;= 0) in any repository rm: cannot remove `watobo-0.9.8.724.gem': No such file or directory  Setting up metasploit (4.3.0-bt1) ... Upgrading Pre-Existing Installation... /opt/metasploit/postgresql/scripts/ctl.sh : postgresql  (pid 1191) already running prosvc is running metasploit is running [*] [*] Attempting to update the Metasploit Framework... [*]   So on it goes for miles, talking about gem caches, rubies, &amp; stuff I wish I had. All up until:  A    lib/gemcache/ruby/1.9.1/gems/state_machine-1.1.2/gemfiles/active_record-2.1.2.gemfile.lock   ...and there it has sat, all night.    If I stop it, will I still get the dpkg error (on the off chance that I won't), or if so what do I need to to resume using apt-get commands and its Super Cow Powers? Why do I always hear remote train horn at night? This is definitely not an illusion, as many people have the same experience. I have usually lived in places miles away from train stations, which makes it unlikely to hear any train horns during the day. However at night, occasionally train horns can be heard. I hope if any one can explain the physics of this effect, like possibly sound travels faster at low temperature. Is there anything in Objective-C similar to C# yield return