Help with objects (scope)

Why does balanceEuro print 850? I thought the value should be updated so it is 3000 * .85.

public class SavingsAccount{

public String owner;
public int balanceDollar;
public double balanceEuro;

public SavingsAccount(String owner, int balanceDollar){
// Complete the constructor
this.owner = owner;
this.balanceDollar = balanceDollar;
this.balanceEuro = balanceDollar * 0.85;

public void addMoney(int balanceDollar){
// Complete this method
this.balanceDollar += balanceDollar;

public static void main(String args){
SavingsAccount zeusSavingsAccount = new SavingsAccount(“Zeus”, 1000);

// Make a call to addMoney() to test your method
System.out.println("Adding " + 2000 + " dollars to the account.");

System.out.println(“The new balance is " + zeusSavingsAccount.balanceDollar + " dollars.”);
System.out.println(“The new balance is " + zeusSavingsAccount.balanceEuro + " euros.”);



Thank you for your help. Just so I can understand this better and for anyone else who may be wondering about this topic, could you explain the logic behind adding this.balanceEuro versus not inputting it and gettting a different result?

The constructor you had set the .balanceDollar and .balanceEuro,
so at that point the balance in .balanceEuro is correct

What you had for the addMoney method

changes the .balanceDollar but
the .balanceEuro is not changed (it is still the same as what was set by the constructor)
so it .balanceEuro no longer match the appropriate .balanceDollar

You can fix that by changing the .balanceEuro to be .balanceDollar * 85 again,
or by adding the appropriate amount to the .balanceEuro
in the addMoney method.