KEMBAR78
Lab 5 | PDF
0% found this document useful (0 votes)
7 views2 pages

Lab 5

The Java program uses JOptionPane to gather user input for a customer's name, bank account number, and beginning balance. It calculates the ending balance at the end of the month by applying a 1% interest rate. Finally, it displays the customer's information and the calculated ending balance in a dialog box.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Lab 5

The Java program uses JOptionPane to gather user input for a customer's name, bank account number, and beginning balance. It calculates the ending balance at the end of the month by applying a 1% interest rate. Finally, it displays the customer's information and the calculated ending balance in a dialog box.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Java Code using JOptionPane:

Import javax.swing.JOptionPane;

Public class BankAccount {

Public static void main(String[] args)

String customerName = JOptionPane.showInputDialog(null,

“This program asks the user for a name,\n”

+ “bank account number, and beginning balance\n”

+ “and then calculates the balance at the end of the month with
corresponding 1% interest.\n\n”

+ “Please enter customer name”,

“Input”, JOptionPane.QUESTION_MESSAGE);

String accountNumber = JOptionPane.showInputDialog(null,

“Please enter account number”,

“Input”, JOptionPane.QUESTION_MESSAGE);

String balanceInput = JOptionPane.showInputDialog(null,

“Please enter beginning balance”,

“Input”, JOptionPane.QUESTION_MESSAGE);

Double beginningBalance = Double.parseDouble(balanceInput);


Double interestRate = 0.01;

Double endingBalance = beginningBalance + (beginningBalance *


interestRate);

String message = String.format(“Customer Name: %s\nAccount


Number: %s\nEnding Balance: %.2f”,

customerName, accountNumber, endingBalance);

JOptionPane.showMessageDialog(null, message,

“Account Information”, JOptionPane.INFORMATION_MESSAGE);

You might also like