Question: Write a Java function called compare that takes 2 numbers and compares them and outputs the result. Your function should compare them for being equality

Write a Java function called compare that takes 2 numbers and compares them and outputs the result. Your function should compare them for being equality (==), inequality (!=), less than (), less than or equal (=). It should print the result of each comparison. For example, if your numbers are 1046 and 2379, the output is:=),>),>

1046 is less than 2379.

1046 is less than equal to 2379.

The prototype for the function is the following: You must write the body of the function.

public void compare(int x, int y)

{

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!