Question: Create a method called compareValues that returns a String, and takes two parameters x and y, both of type int. The body of your

Create a method called compareValues that returns a String, and takes two  

Create a method called compareValues that returns a String, and takes two parameters x and y, both of type int. The body of your method should be a large comparison statement that does the following. If x is larger than y, it should return the string "x is larger than y" with x and y in the string replaced with the values of x and y. (Recall the operator for String concatenation.) If y is larger than x, it should return the string "y is larger than x", again with x and y replaced by the values of x and y. Finally, of x and y have the same value, it should return the string "the two values are equal" Test your code by calling compareValues three times, once with x larger than y, once with y larger than x, and once with the values the same to verify that you get the correct response each time. Step 1: Start DrJava If you are on your own computer, you can load DrJava by foilowing the links on the General Information page. If you are on a lab machine, DrJava should be available. Step 2: Writing Some Java Code Reset the interactions pane. In this lab, you will be typing in a method. You can type it directly into the interactions pane. If you get an error, just enter the corrected code. If you get really mixed up, you can reset the interactions pane and try again.

Step by Step Solution

3.40 Rating (156 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Program Program to be saved as TestCompareValuesjavapublic class TestCompareV... View full answer

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!