Last active
October 17, 2015 06:40
-
-
Save johnSerrano/56ef92270f816a88b391 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Account | |
{ | |
private double checkingBalance; | |
private double savingsBalance; | |
public Account ( Double balance1, Double balance2 ) | |
// constructor | |
{ | |
checkingBalance = balance1; | |
savingsBalance = balance2; | |
} | |
public void setsavingsBalance( double balance2 ) | |
{ | |
if (balance2 >= 0) | |
savingsBalance = balance2; | |
else | |
System.out.println("Invalid amount"); | |
} | |
public void creditChecking( double amount ) | |
{ | |
checkingBalance = checkingBalance + amount; | |
} | |
public void creditSavings( double amount ) | |
{ | |
savingsBalance = savingsBalance + amount; | |
} | |
public double getCheckingBalance() | |
{ | |
return checkingBalance; | |
} | |
public double getSavingsBalance() | |
{ | |
return savingsBalance; | |
} | |
public void debitChecking( double amount ) | |
{ | |
if (amount>checkingBalance) | |
System .out.println("Transaction amount exceeded checking balance" ); | |
else | |
checkingBalance = checkingBalance - amount; | |
} | |
public void debitSavings( double amount ) | |
{ | |
if (amount>savingsBalance) | |
System .out.println("Transaction amount exceeded checking balance" ); | |
else | |
savingsBalance = savingsBalance - amount; | |
} | |
public void moveFromSavingsToChecking(double amount) | |
{ | |
if (amount>savingsBalance){ | |
System .out.println("Transaction amount exceeded checking balance" ); | |
} | |
else { | |
checkingBalance -= amount; | |
savingsBalance += amount; | |
} | |
} | |
public void moveFromCheckingToSavings(double amount) | |
{ | |
if (amount>checkingBalance){ | |
System .out.println("Transaction amount exceeded checking balance" ); | |
} | |
else { | |
checkingBalance += amount; | |
savingsBalance -= amount; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment