
22-Jan-2007, 07:58
|
|
New Member
|
|
Join Date: Mar 2006
Posts: 12
|
|
|
Need Help with my program
A bank offers its customers four types of account:
Current account
Standard saving account
Fixed-term saving account with higher rate of interest
An offshore account
The interest rate for these accounts is:
1.5% per year on current account
6% per year on the standard saving account
7% per year of fixed term account
8% per year for an offshore account
For each customer we need:
Name
Address
Telephone no.
Account number
Type of account
Tax code
Some of the required standard operations are:
Create an account,
Deposit money into an account
Withdraw money from an account,
etc.
Design, write and test a program that:
1. Identifies the account that earns minimum interest in a year.
2. Identify the account that earns maximum interest in a year.
3. Given a customer name and balance projects the amount of interest to be paid to that account in a year.
4. Calculates the total amount of the interest that a bank needs to pay out to all its customers at the end of a year.
If time permits, you may explore the concurrent feature of this problem.
Solution
JAVA Code:
import glos.*;
import java.awt.*;
import javax.swing.*;
public class Bank extends JPanel {
protected final static String names [] = {" Account Customer", " Name ", "Address ",
" Telephone Number"," Account number ", " Type of account ", " Tax code ", " Balance ",
"Transaction Amount" };
public void final int ( ACCOUNT CUSTOMER = 0, NAME = 1, ADDRESS = 2, TELEPHONE NUMBER. = 3,
ACCOUNT NUMBER = 4, TYPE OF ACCOUNT = 5, TAX CODE = 6, BALANCE = 7, TRANSACTION = 8);
public BankUI()
{
this (8);
}
public BankUI ( int mySize )
{
size = mySize;
labels = new JLabel[ size ];
fields = new JTextField[ size ];
for ( int i = 0; i < labels.length; i++ )
fields[ i ] = new JTextField();
innerPanelCenter = new JPanel();
innerPanelCenter. setLayout( new GridLayout ( size, 2 ));
for ( int i = 0; i< size; i++ ){
innerPanelCenter.add ( labels[ i ] );
innerPanelCenter.add ( fields[ i ] );
}
doTask = new JButton();
doTask8 = new JButton();
innerPanelSouth = new JPanel();
innerPanelSouth.add( doTask8);
innerPanelSouth.add( doTask);
setLayout( new BorderLayout() );
add( innerPanelCenter, BorderLayout.CENTER );
add( innerPanelSouth, BorderLayout.SOUTH );
validate();
}
public JButton getDoTask() { return doTask;}
public JButton getDoTask8() { return doTask8;}
public JTextField[] getFileds() { return fields;}
public void clearFields()
{
for ( int i = 0; i < size; i++ )
fields[ i ].setText( " " );
}
public void setFieldValues( String s[] )
throws IllegalArgumentException
{
if ( s.length != size )
throw new IllegalArgumentException
{
if ( s.length !=size )
throw new IllegalArgumentException( "There must be " + size + " Strings in the array" );
for ( int i = 0; i < size; i++ )
fields [i].setText ( s [i] );
}
public String[] getFieldValues()
{
String values[] = new String [ size ];
for ( int i = 0; i< size; i++ );
fields[ i ].setText( s[i].getText();
return values;
}
}
import java.io.Serializable;
public class BankAccountRecord implements Serializable {
private int account customer;
private int name;
private int address;
private int telephone number.;
private int account number;
private int type of account;
private int tax code;
private int balance;
public BankAccountRecord();
{
this ( 0, '' '', '' '', 0, 0, '' '', 0, 0.0 );
}
public BankAccountRecord( int account cust, String name, String address, int telephone no., int acct no., String type of acct, int tax code, double bal )
{
setAccountCustomer ( account cust );
setName ( name );
setAddres ( address );
setTelephoneNumber ( telephone no. );
setAccountNumber ( acct no. );
setTypeOfAccount ( type of acct );
setTaxCode ( tax code );
setBalace ( bal );
}
public void setAccountCustomer ( int account cust )
{
accountCustomer = account cust;
}
public int getAccount() { return account customer; }
public String getName() { return name;}
{
name = name;
}
public void setName ( String name }
{
public String getAddress() { return address; }
{
address = address;
}
public void setAddress ( String address )
public void setTelephoneNumber ( int telephone no. )
{
telephone number = telephone no.;
}
public int getTelephoneNumber() { return Telephone number;}
public void setAccountNumber ( int acct no. )
{
accountNumber = acctNo.;
{
public int getAccountNumber () { return account number }
public void setTypeOfAccount ( String TypeOfAcct )
{
typeOfAccount = tyopeOfAcct;
}
public String getTypeOfAccount (){ return typeOfAccount }
public void setTaxCode ( int taxCode )
{
taxCode = taxCode;
}
public int getTaxCode ( ){ return taxCode }
public void setBalance ( double bal )
{
balance = bal;
}
public double getBalance(){ return balance;}
}
}
}
Last edited by LuciWiz : 22-Jan-2007 at 08:37.
Reason: Please insert your Java code between [java] & [/java] tags
|
|