* GUI Electric Bill Program
package guielectricbill;

//import the package to do GUI input/output
import javax.swing.*;

public class GUIElectricBill {

public static void main(String[] args) {
       // declare variable to store user input
        String accountNumber, customerName, address; 
        int KWH;
        double amountDue;

        // Welcome customer to the Electric Bill Calculation Program
        JOptionPane.showMessageDialog(null, "Welcome to the Electric Bill Calculation Program!", 
                "Welcome", JOptionPane.INFORMATION_MESSAGE);

        //Ask the customer for their account number
        accountNumber = JOptionPane.showInputDialog("Please enter your account number and press OK:");

        //Ask the customer for their name
        customerName = JOptionPane.showInputDialog("Please enter your name and press OK:");

        //Ask the customer for their address
        address = JOptionPane.showInputDialog("Please enter your address "
                + "(street, city, state and zip) and press OK:");

        //Ask the customer for their KWH usuage
        KWH = JOptionPane.showInputDialog("Please enter the KWH used and press OK:");

        // Calculate amount due
        amountDue = KWH * 0.0624;

        // Display the customers bill 
        JOptionPane.showMessageDialog(null, "Account Number: " + accountNumber + "/n"
                + "Name: "+ customerName + "/n" + "Address: " + address + "/n" 
                + "KWH Used: " + KWH + "/n" + "Amount Due: " + amountDue, "Your Bill", 

        // Thank customer for using program        
        JOptionPane.showMessageDialog(null, "Thank you for using the Electric Bill Calculation!", 
                "Good Bye", JOptionPane.INFORMATION_MESSAGE);

        // Use System.exit(0); statement when only working with GUIs
        // It causes Java to properly terminate your program



I have included a picture of what kind of dialog box I want to achieve, but I don't know how to go about it.
Many thanks in advance.

This article has been dead for over six months. Start a new discussion instead.