Hey,
So Im a real Java Beginner, so forgive me if this is a stupid question.
I've been having trouble trying to get an if statement to return a value.
I wonder if it is to do with the return type or Data type Im using.
public double oF() { if (displayValue > 100) { JOptionPane.showMessageDialog(frame, "The Temperature scale Celcius does not allow numbers above 100, Please enter a number lower that 100", "Error", JOptionPane.INFORMATION_MESSAGE); } else if (displayValue < -273) { JOptionPane.showMessageDialog(frame, "The Temperature scale Celcius does not allow numbers below -273, Please enter a number greater than -273", "Error", JOptionPane.INFORMATION_MESSAGE); } else return displayValue = (9 * displayValue)/ 5 + 32; }
This code gives me the error: missing return statement. I understand why that is (I think!), and I need to find a way around it, because what Ive been
trying to do is get it to do the calculation only if neither if statement is run. However, because It's in an if statement, public double doesn't seem to realise that I am trying to return something, but only inside an if statement.
Could anyone tell me what I'm doing wrong ?
Thank you,
Angus90