package class5_2_PackagesAndRandomNumberGenerators; // MSOE. Dr. Yoder. 07 October 2015. import javax.swing.*; import java.text.DecimalFormat; public class DecimalFormatExample { public static void main(String[] args) { final double DOLLARS_PER_POUND = 0.99; // They're organic. String poundString = JOptionPane.showInputDialog(null, "Please enter the number of bananas\n" + "you would like to purchase:"); double poundsBananas = Double.parseDouble(poundString); double price = DOLLARS_PER_POUND * poundsBananas; DecimalFormat formatter; formatter = new DecimalFormat("#.##"); JOptionPane.showMessageDialog(null, "The bananas will cost: $" +formatter.format(price)); } }