Welcome to Dream.In.Code
Become a Java Expert!

Join 149,492 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,300 people online right now. Registration is fast and FREE... Join Now!




Need some help

 
Reply to this topicStart new topic

Need some help, 2 Problems

Splinter
20 Mar, 2007 - 08:17 AM
Post #1

New D.I.C Head
*

Joined: 20 Mar, 2007
Posts: 1


My Contributions
I am working on this code for a class. I do not typically ask for help but I know I am just missing something stupid on my part. I have all of it done by I have 2 errors one at line 26 and the other at 33. My problem is for the life of me I cannot figure out how to correct this. If anyone is willing to help I would much apprecitate it if not thanks anyways.
CODE

public class BankAccount
{
  private double balance;
  private String name;
  private double newBalance;
  
  public BankAccount(String owner)
{
  this.name = owner;
  this.balance = 0.00;
}

  public BankAccount(String name, double balance)
  {
    this.name = name;
    this.balance = balance;
  }
  //methods
  public String toString()
  {
    return this.name + " has " + this.balance + " in the account";
  }
  
  public double deposit(double amnt)
  {
      amnt + this.balance = this.newBalance;
      newBalance = balance;
      return balance;
  }
  
  public double withdraw( double wthamnt )
  {
    balance - wthamnt = newBalance;
    newBalance = balance;
    return balance;
    }
  public double getBalance()
  {
    return balance;
  }
}


~Added [code] Tags - skyhawk133

This post has been edited by Splinter: 20 Mar, 2007 - 08:20 AM
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Need Some Help
20 Mar, 2007 - 09:00 AM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 7,302



Thanked: 66 times
Dream Kudos: 500
Expert In: Everything

My Contributions
Can you post the exact error messages that you are getting?

User is online!Profile CardPM
+Quote Post

thearchitect2
RE: Need Some Help
20 Mar, 2007 - 09:56 AM
Post #3

New D.I.C Head
*

Joined: 28 May, 2005
Posts: 12


My Contributions
You had assignments mixed up. They're just some simple mistakes that beginners make. No worries!

for line 26:
CODE
amnt + this.balance = this.newBalance;

should be

CODE
this.newBalance = amnt + this.balance;


and for line 33:
CODE
balance - wthamnt = newBalance;

should be

CODE
newBalance = balance - withamt;


Remember, you're always assigning the left side to the right side of the equals sign.
And you probably wanna switch around the lines right after that. I think that's what you're looking for to get the right result.

This post has been edited by thearchitect2: 20 Mar, 2007 - 09:57 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 05:42PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month