Hi everyone i have this simple banking program here and i was hoping someone could help me jazz it up.. Something simple like making it easier to use or making it look better. Just trying to go beyond what was asked for..

import javax.swing.JOptionPane;

class MiniLab5z
{
	public static double newBalance=0;
	public static double balance=0;
	public static double adjustment=0;
	public static String response;
	public static String moreBankingBusiness;

public static void main(String[] args)
{

	try

{
	moreBankingBusiness = JOptionPane.showInputDialog("Do you want to do some banking?");
	moreBankingBusiness=moreBankingBusiness.toUpperCase();
}

	catch (Exception e)

{

// Print out the exception that occurred
	System.out.println("Invalid Button Press - "+e.getMessage());
	System.exit(0);

}

	while(moreBankingBusiness.equals("YES"))
{

	try

{
	response=JOptionPane.showInputDialog
	("What would you want to do ?\n1.Deposit\n2.Withdraw\n3.GetBalance");
	if(response.equals(""))
{
	JOptionPane.showMessageDialog
	(null,"You nust make an entry in the InputBox.");
	System.exit(0);
}

	if(response==null)
{
	JOptionPane.showMessageDialog(null,"You clicked on the Cancel button.");
	System.exit(0);
}
	int ch = Integer.parseInt(response);

	switch (ch)
{

		case 1:
		deposit();
		break;
		case 2:
		withdrawal();
		break;
		case 3:
		balance();
		break;

		default :
		JOptionPane.showMessageDialog(null,response+" is not vaild banking function");
		break;

}

	balance=newBalance;
	moreBankingBusiness=JOptionPane.showInputDialog("Do you have more banking business?");
	moreBankingBusiness=moreBankingBusiness.toUpperCase();

}

	catch (Exception e)

{
// Print out the exception that occurred

	System.out.println("Invalid type of Input or Button Pressed - "+e.getMessage());
	System.exit(0);

}
}//end of while

}

public static void deposit()
{
	try
{
	adjustment=Double.parseDouble(JOptionPane.showInputDialog("Enter the Deposit Amount"));
	newBalance=balance+adjustment;
	JOptionPane.showMessageDialog(null,"***SMILEY NATIONAL BANK***\n\n"+
	"Old Balance is:"+balance+"\n"+"Adjustment is :"+adjustment+"\n"+
	"New Balance is:"+newBalance+"\n");
}

	catch (Exception e)

{
// Print out the exception that occurred
	System.out.println("Invalid operation - "+e.getMessage());
	System.exit(0);
}
}

public static void withdrawal()
{

	try

{
	adjustment=Double.parseDouble(JOptionPane.showInputDialog("Enter the Withdrawal Amount"));
	if (balance-adjustment>=0)
{
	newBalance=balance-adjustment;
	JOptionPane.showMessageDialog
	(null,"***SMILEY NATIONAL BANK***\n\n"+
	"Old Balance is:"+balance+"\n"+
	"Adjustment is :"+adjustment+"\n"+
	"New Balance is:"+newBalance+"\n");
}
	else
	JOptionPane.showMessageDialog
	(null,"***SMILEY NATIONAL BANK***\n\n"+
	"Insufficient funds to withdraw.");
}

	catch (Exception e)

{
// Print out the exception that occurred

	System.out.println("Invalid operation - "+e.getMessage());
	System.exit(0);

}

}

public static void balance()
{

	JOptionPane.showMessageDialog(null,"***SMILEY NATIONAL BANK***\n\n"+"Your Current Banace is:"+balance);

}
}

Recommended Answers

All 2 Replies

You are asking US to make it look better/work better, so that you get a better grade for working harder? You gotta be kidding me.

If you have a question please ask it, but we don't do any homework assignments around here.

Instead of all those text-style menus in dialogs, you could pop up a small window or dialog with buttons for each of the functions - that would be a more Windows-like approach. You could also decorate that window with a bank logo in the background.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.