Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Java Programming question


  • Please log in to reply

#1
k_barta

k_barta

    Member

  • Member
  • PipPip
  • 21 posts
The class variable giftsTotal is meant to keep a running total as the program uses the other class methods, but all it currently does is output the value of the last method called. So what do I need to do in order to make this work the way I want it to?


public class Gift {

private double giftsTotal;

public void enterDollars(double input){
this.giftsTotal += input;
System.out.println("giftsTotal = "+ this.giftsTotal);
}
public void enterEuros(double input){

final double EURO_CONVERSION_RATE = 1.24;
this.giftsTotal = input * EURO_CONVERSION_RATE;
System.out.println("giftsTotal = "+ this.giftsTotal);
}
public void enterYen(double input){

final double YEN_CONVERSION_RATE = 0.0092;
this.giftsTotal = input * YEN_CONVERSION_RATE;
System.out.println("Working in enterYen.");
}

public double getTotalSavings(){
return giftsTotal;
}
  • 0

Advertisements


#2
k_barta

k_barta

    Member

  • Topic Starter
  • Member
  • PipPip
  • 21 posts
Never Mind. I'm an idiot! I found the problem after a little experimentation
  • 0

#3
IO-error

IO-error

    Member

  • Member
  • PipPipPip
  • 276 posts
What was your problem?

I'm getting into Java too, so from other's mistakes I can learn too.
If it's not too much of trouble for you.
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP