English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

iv.Write a program named TestAccount in which you instantiate two CheckingAccount objects and display the account number, balance, and minimum balance without fee for both accounts.

2006-08-09 23:27:25 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

java programming language

2006-08-09 23:59:49 · update #1

Both of your answer has error when i compile it

2006-08-10 05:24:12 · update #2

2 answers

What programming language is this?

Your two objects should be an object set/get class and a server class.
For example:
//First object class - Get/Set Object Class
public class CheckingAppObj
String accnum;
String accbalance;
String accmin;
{
public void setAccountNumber(String x)
{
accnum = x;
}
public String getAccountNumber()
{
return accnum;
{
// Do the same thing for the other two parameters and create a Get/Set method for Balance and Minimum.
}


************



//Second object class - Server Class
public class CheckingServer
{
public void getAccountInfo(CheckingAppObj obj)
{
// do your server connection here and get the data from your table
Vector resultVec;
Object[] aRow = (Object[])resultVec.elementAt(i);
//As it reads the data, set it in your CheckingAppObj
obj.setAccountNumber(aRow[0]);
obj.setAccountBalance(aRow[1]);
obj.setAccountMin(aRow[2]);
}
}

Then in your Servlet or Action class, all you need to do is instantiate your server and your obj class and then retrieve the data.

public class TestAccount
{
public void showAccountInfo()
{
CheckingServer server = new CheckingServer();
//Call the server first
CheckingAppObj obj = new CheckingAppObj();
server.getAccountInfo(obj);
//Then just display results
System.out.println( obj.getAccountNumber() );
System.out.println( obj.getAccountBalance() );
System.out.println( obj.getAccountMinimum() );
}
}

EDIT: THat is because we dont know where youre getting your data from. Are you reading from a table? CAn you hardcode it? What is your SQL server? We cant write everything for you if we dont know where youre getting your data. Thats the part you need to fill in.

2006-08-09 23:55:12 · answer #1 · answered by Sean I.T ? 7 · 0 0

In Java
public class Account
{

//members of account class
public long accountnumber;
public long balance;
public long minbalance;
Account(long acno, long bal, long minbal)
{
//Initialize the members
accountnumber=acno;
balance=bal;
minbalance=minbal;
}

}
class TestAccount
{
public static void main(Strings arg[])
{
Account obj1=new Account(12345,1000,500);
Account obj1=new Account(12346,10500,500);
System.out.println(obj1.accountnumber);
System.out.println(obj1.balance);
System.out.println(obj1.minimumbalance);
//Similarly for obj2
//Better use getter methods to display the values and make the variable private


}
}

2006-08-10 07:55:13 · answer #2 · answered by Aryan 2 · 1 0

fedest.com, questions and answers