Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started