In: Computer Science
The < and == operators for the class Record have already
been implemented for you. Write the code necessary to complete the
>, <=,>= and != operators. (hint: you do not need to know
anything about the Record class to complete)
Below is the solution:
public class Record {
public static void main(String[] args) {
int a = 5, b = 4;
// for > operator true or
false
System.out.println((a > b)); //
returns true
a = 4;
b = 5;
System.out.println((a > b)); //
returns false
// for <= true or false
a = 5;
b = 4;
System.out.println((a <= b)); //
returns false
a = 4;
b = 5;
System.out.println((a <= b)); //
returns true
// for >= true or false
a = 5;
b = 4;
System.out.println((a >= b)); //
returns true
a = 4;
b = 5;
System.out.println((a >= b)); //
returns false
// for != true or false
a = 5;
b = 4;
System.out.println((a != b)); //
returns true
a = 5;
b = 5;
System.out.println((a != b)); //
returns false
}
}
output:
true
false
false
true
true
false
true
false