corky22
06-16-2009, 08:50 PM
Given the Banking class, your job is to follow the script of actions given at the bottom of the assignment by entering them as statements in the main part of the class BankingDriver. It's BankingDriver.java that you will submit as your solution to this problem.
public class Banking{
private String name;
private int checkMoney;
private int saveMoney;
public Banking(String who, int checking, int saving){
name = who;
checkMoney = checking;
saveMoney = saving;
}
public String getName(){
return name;
}
public int getCheckMoney(){
return checkMoney;
}
public int getSaveMoney(){
return saveMoney;
}
public int getTotalMoney(){
return(checkMoney+saveMoney);
}
public void setCheckMoney(int amt){
checkMoney = amt;
}
public void setSaveMoney(int amt){
saveMoney = amt;
}
public String toString(){
return(name + " checking: " + checkMoney + " savings: " + saveMoney);
}
}
Here is what your code must do:# Create an object called nicksAcct. Nick has $400 in his checking account, and $500 in his savings account.
Create an object called carolsAcct. Carol has $600 in her checking account, and $700 in her savings account.
Print out the total amount of money in both accounts (you must use methods from the class here).
Add $100 to Nick's checking account.
Print out statisics on Nick's account. This statement: System.out.println(nicksAcct); will do the trick.
In a series of statements, move all of the money in Nick's account - both checking and savings - to Carol's savings account. This should leave Nick penniless at the end.
Print out statisics on Nick's account
Print out statisics on Carol's account
public class Banking{
private String name;
private int checkMoney;
private int saveMoney;
public Banking(String who, int checking, int saving){
name = who;
checkMoney = checking;
saveMoney = saving;
}
public String getName(){
return name;
}
public int getCheckMoney(){
return checkMoney;
}
public int getSaveMoney(){
return saveMoney;
}
public int getTotalMoney(){
return(checkMoney+saveMoney);
}
public void setCheckMoney(int amt){
checkMoney = amt;
}
public void setSaveMoney(int amt){
saveMoney = amt;
}
public String toString(){
return(name + " checking: " + checkMoney + " savings: " + saveMoney);
}
}
Here is what your code must do:# Create an object called nicksAcct. Nick has $400 in his checking account, and $500 in his savings account.
Create an object called carolsAcct. Carol has $600 in her checking account, and $700 in her savings account.
Print out the total amount of money in both accounts (you must use methods from the class here).
Add $100 to Nick's checking account.
Print out statisics on Nick's account. This statement: System.out.println(nicksAcct); will do the trick.
In a series of statements, move all of the money in Nick's account - both checking and savings - to Carol's savings account. This should leave Nick penniless at the end.
Print out statisics on Nick's account
Print out statisics on Carol's account