0
/*
 * 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", 
                JOptionPane.INFORMATION_MESSAGE);

        // 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
        System.exit(0);


    }
}   

7701c78c86f398ac5d697db08ef39f7d

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.

2
Contributors
1
Reply
9
Views
3 Years
Discussion Span
Last Post by JamesCherrill
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.