troubleshooting Question

Java program issue

Avatar of Stryker1990
Stryker1990Flag for United States of America asked on
Java
18 Comments1 Solution319 ViewsLast Modified:
Hi, I am working on a Hiearchy bank program that takes the info from the bankTest  class and deals with it accordingly, however, I am having issues, it compiles and runs but the output does not seem right. I think Im having issues with the contructors and/or set and get methods. Any input or pointing out what I obviously did wrong would be great, Thanks.

First set of code will be bankTest followed by 3 comments from myself that are the classes.
class bankTest
 
{
   public static void main ( String argv[] )
   {
      double interest;
 
      Account test = new Account();
      Account act = new Account(200.00);
      SavingsAccount sav = new SavingsAccount(1500.00, 0.0525);
      CheckingAccount chk = new CheckingAccount(145.38, 0.10);
 
      // Test constructors
      System.out.println("test account balance is " + test.getBalance() );
      System.out.println("act account balance is " + act.getBalance() );
      System.out.println("sav account balance is " + sav.getBalance() );
      System.out.println("sav account interest is " + sav.getInterestRate() );
      System.out.println("chk account balance is " + chk.getBalance() );
      System.out.println("chk account fee is " + chk.getFee() );
 
     // Test Account superclass
     act.credit(55.00);
     System.out.println("act balance is " + act.getBalance() );
     if (act.debit(75.00))
          System.out.println("act balance is " + act.getBalance());
     else
          System.out.println("No debit (would overdraw account)");
 
     if (act.debit(275.00))
          System.out.println("act balance is " + act.getBalance());
     else
          System.out.println("No debit (would overdraw account)");
 
     System.out.println("act balance is " + act.getBalance() );
 
     act.setBalance(12345.67);
     System.out.println("sav account balance is " + sav.getBalance() );
 
 
     // Test SavingsAccount
     sav.debit(250.00);
     System.out.println("sav account balance is " + sav.getBalance() );
     sav.credit(575.25);
     System.out.println("sav account balance is " + sav.getBalance() );
     interest = sav.calculateInterest();
     System.out.println("Interest is: " + interest);
     sav.credit(interest);
     System.out.println("sav account balance after interest is: " + sav.getBalance() );
     sav.setInterestRate(.065);
     System.out.println("new interest rate is " + sav.getInterestRate() );
     sav.setBalance(123456.78);
     System.out.println("sav account balance is " + sav.getBalance() );
 
     // Test CheckingAccount
     chk.credit(135.25);
     System.out.println("chk account balance is " + chk.getBalance() );
     chk.debit(123.45);
     System.out.println("chk account balance is " + chk.getBalance() );
     chk.debit(456.78);
     System.out.println("chk account balance is " + chk.getBalance() );
     chk.setFee(0.25);
     System.out.println("chk account fee is " + chk.getFee() );
     chk.setBalance(1234.56);
     System.out.println("chk account balance is " + chk.getBalance() );
 
   }
}
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 18 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 18 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros