i need help with converting celsius to fahrenheit and vice versa in my program. for example, if someone would input 0C for the first temperature and 32F for the second temperature, i need to convert one of these temperatures so that my equals method can recognize that they are equal and output that both temperatures are equal.
I've attempted to do this with the calculateCelsius() method but it doesnt work if i try to run it in my driver program
Thank you for any help
public double getValueF()
{
if(scale=='F')
return value;
else
return(9*(value/5)+32);
}
public double getValueC()
{
if(scale=='C')
return value;
else
return(5*(value-32)/9);
}
public char getScale()
{
return scale;
}
public void setValue(double t)
{
value = t;
}
public void setScale(int s)
{
if(s==1)
scale = 'C';
else
scale = 'F';
}
public double caluculateCelsius()
{
if(scale=='F')
value = (5*(value-32)/9);
return value;
}
public boolean equals(Temperature temp2)
{
return ((this.value==temp2.value)&&(this.scale==temp2.scale));
}