Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Usability

Authors: Jakob Nielsen, Raluca Budiu

1st Edition

0133122131, 9780133122138

More Books

Students also viewed these Programming questions