Question

In: Computer Science

The < and == operators for the class Record have already been implemented for you.

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)

Solutions

Expert Solution

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


Related Solutions

Identify three conditions that would need to be implemented (or have already been implemented) in your...
Identify three conditions that would need to be implemented (or have already been implemented) in your organization to create a culture of innovation and change.
Identify three conditions that would need to be implemented (or have already been implemented) in your...
Identify three conditions that would need to be implemented (or have already been implemented) in your organization to create a culture of innovation and change.
Identify three conditions that would need to be implemented (or have already been implemented) in your organization to create a culture of innovation and change.
Identify three conditions that would need to be implemented (or have already been implemented) in your organization to create a culture of innovation and change.
(Javascript) /* * USER HAS ALREADY BEEN IMPLEMENTED FOR YOU: * User has the following properties:...
(Javascript) /* * USER HAS ALREADY BEEN IMPLEMENTED FOR YOU: * User has the following properties: * name: string * birthday: Date * * User has the following method: * getDayBorn: Returns the day of the week that the user was born * example: Wednesday */ function User(name, birthday) { this.name = name; this.birthday = birthday; this.getDayBorn = function() { var days = [`Sunday`,`Monday`,`Tuesday`, `Wednesday`,`Thursday`,`Friday`,`Saturday`]; return days[this.birthday.getDay()]; } } /* * YOUR TASK IS TO IMPLEMENT CHIRP: * Chirp has...
Identify three conditions that would need to be implemented (or have already been implemented) in your Lululemon Athletica to create a culture of innovation and change.
Identify three conditions that would need to be implemented (or have already been implemented) in your Lululemon Athletica to create a culture of innovation and change.
Suppose the interface and the class of stack already implemented, Write application program to ( java)...
Suppose the interface and the class of stack already implemented, Write application program to ( java) 1- insert 100 numbers to the stack                         2- Print the even numbers 3- Print the summation of the odd numbers
Some database administrators assume their role managing existing databases have already been fully designed and implemented....
Some database administrators assume their role managing existing databases have already been fully designed and implemented. Throughout the career of a database administrator it is likely, however, that there will be need to design a new database for the organization. There are an array of factors that influence the approach a database administrator will take when designing a new database, including the objectives of the database, the data in which it will be stored, the location and activities of the...
Suppose the interface and the class of stack already implemented, Write application program to 1- insert...
Suppose the interface and the class of stack already implemented, Write application program to 1- insert 100 numbers to the stack 2- Print the even numbers 3- Print the summation of the odd numbers
You have already implemented a Queue before that works on First Come First served basis. In...
You have already implemented a Queue before that works on First Come First served basis. In this assignment you are to implement a class that works on Last In First Out. Such a structure is called a Stack. It only allows two operations add (named push) and remove (named pop). Push only allows adding any data item to the last entry place. Pop only allows you to remove the last added entry from the stack. For example if your stack...
Some DRM systems have been implemented on open systems and some have been implemented in closed...
Some DRM systems have been implemented on open systems and some have been implemented in closed systems. a. What is the primary advantage of implementing DRM on a closed system? b. What is the primary advantage to implementing DRM on an open platform?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT