troubleshooting Question

[noob][java] method void, int and others.

Avatar of Troudeloup
Troudeloup asked on
Programming Languages-OtherJavaAlgorithms
12 Comments9 Solutions301 ViewsLast Modified:
This is a noob code to practice some java code.

for use of method, even though the return type is void, it's still possible to modify the values of the object.

what are other return types for?






public class usebankaccount
{

      public static void main(String[] args)
      {
            
            bankaccount acct1 = new bankaccount();
            acct1.deposit(500);
            acct1.show();
            
            //  System.out.println ( acct1 );
            
      }
      
      
}




class bankaccount
{
      double penny;
                  
      
      public bankaccount()
      {
            System.out.println ("an account has been opened and it has 0 dollars.");
      }
      
      public bankaccount(double pennies)
      {
            double penny = pennies;
            System.out.println ("an account has been opened and it has" + penny + "dollars.");
      }
      
      public ba (double pennies)
      {
            double penny = pennies;
            System.out.println ( " An instance of the object ba has been created and " + penny + "is its balance." )
      }
            
            
      
      public void withdraw(double subtract)
      {
            penny = penny - subtract;
            System.out.println(subtract + "has been withdrew, the account still has" + penny + "dollars.");
            
      }
      
      public void deposit (double add )
      {
            penny = penny + add;
            System.out.println(add + "has been deposited, the account now has" + penny + "dollars.");
      
      }

      public void show()
      {
            System.out.println("This account has " + penny + " dollars.");
            
      }
      
      
}



ASKER CERTIFIED SOLUTION
Mick Barry
Java Developer
Join our community to see this answer!
Unlock 9 Answers and 12 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 9 Answers and 12 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