/* The program demonstrate how to convert Strings into Numbers * */ import javax.swing.*; public class ConvertNum { public static void main(String[] args) { // Gets the first number String firstnum = JOptionPane.showInputDialog("Enter a number"); // Gets the second number String secnum = JOptionPane.showInputDialog("Enter another number"); double sum = 0.0; // Convert the Strings into a Double double num1 = Double.parseDouble(firstnum); double num2 = Double.parseDouble(secnum); // Sums up the number sum = num1 + num2; // Output the sum into the screen JOptionPane.showMessageDialog(null, "The sum of the two number is " + sum); } }