Hello!
I am trying to figure out how to use the GUI to input an integral, perform a calculation with the input data, and display it in a message box. For example, input weight in kilograms and display weight in pounds.
The problem I am having is with respect to JOptionPane.showMessageDialog. Am I not allowed to display via dialog box using this method?
import javax.swing.JoptionPane; public static void main(String[] args) { double weightK; double weightP; String weightKstr; String weightPstr #prompt user to input their weight in kilograms weightKstr = JOptionPane.showInputDialog ("Enter your weight in kilograms: "); weightK = Double.parseDouble(weightKstr); # The conversion weightP = (weightK * 2.2); weightPstr = "Weight: " + weightP + "pounds"; # Displays the weight in pounds in a plain message dialog box OptionPane.showMessageDialog(null, weightPstr, "conversion", JoptionPane.PLAIN_MESSAGE); System.exit(0); }
Thanks in advance!