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);
}
}