Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Temperature Average Keeps Sending Zero

$
0
0
Hi, I'm having a hard time with my assignment.
I'm not sure if I'm specifying it right.
So far I've come up with this:

public class TemperatureAverager{
  private double sum;
  private int count;
  
  public TemperatureAverager(){
    this.sum = 0.0;
    this.count = 0;
  }
  
  public int averageTemperature(){
    return (int)(Math.round(this.sum/this.count));
  }
  
  public void enterCelsius(double celsius){
   this.sum = (9.0/5.0)*(celsius + 32);
  }

  public void enterFahrenheit(double fahrenheit){
   this.sum = (5.0/9.0)*(fahrenheit - 32);
  }
}

Viewing all articles
Browse latest Browse all 51036

Trending Articles