tokola
tokola

Reputation: 15

Required variable found value java?

I have been working on a program for class that compares values of two temps. I've got everything working but on my very last method I am getting an error, even though it is built the exact same. The is not equal to function is saying required variable found value and wont run, even though the rest that are built the same way do run?

 public boolean isLessThan(Temperature t){

 return t.get()>this.get();
 }
 public boolean isGreaterThan(Temperature t){
    return t.get()>this.get();
 }
 public boolean isEqual(Temperature t){
    return (Math.abs(this.get()-t.get()))<=10E-12;

 }

 public boolean isGreaterThanOrEqual(Temperature t){
     return t.get()>=this.get();

 }
 public boolean isLessThanorEqual(Temperature t){
     return (t.get()<=this.get());}

 public boolean isNotEqualTo(Temperature t){
    return Math.abs(this.get()-t.get())=>10E-12;
 }



}

Upvotes: 1

Views: 645

Answers (2)

Alex
Alex

Reputation: 1008

Well... the operator is wrong.

<= // less or equal
>= // bigger or equal

Upvotes: 3

Elliott Frisch
Elliott Frisch

Reputation: 201467

Your syntax here

return Math.abs(this.get()-t.get())=>10E-12;

(assuming you want greater then or equal to) needs to be

return Math.abs(this.get()-t.get()) >= 10E-12;

Also, this

public boolean isLessThan(Temperature t){
  return t.get()>this.get();
}

should be

public boolean isLessThan(Temperature t){
  return t.get() < this.get();
}

Upvotes: 1

Related Questions