Create a method called compareValues that returns a String, and takes two parameters x and y,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Answer rating: 100% (QA)
Program Program to be saved as TestCompareValuesjavapublic class TestCompareV... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Create a method called depth that will return an int representing the level or depth of the given node from the root.
-
Modify the ExpressionTree class to create a method called draw that will graphically depict the expression tree.
-
A construction company manages two large building projects. Both require about 50 employees with comparable skills. At a meeting, the site managers from the two projects got together to estimate the...
-
According to the Internal Revenue Service (IRS), the chances of your tax return being audited are about 1 in 100 if your income is less than $1 million and 9 in 100 if your income is $1 million or...
-
Suppose the United States maintains a price floor for spinach. Why might this policy decrease revenues for spinach farmers?
-
How does an entity choose its tax year? Is it the same process no matter the type of tax year-end the taxpayer adopts?
-
What conditions are important in independent internal verification.
-
Gardi Manufacturing uses normal costing for its job-costing system, which has two direct-cost categories (direct materials and direct manufacturing labor) and one indirect-cost category...
-
A spherical shell contains three charged objects. The first and second objects have a charge of -15.0 nC and 34.0 nC, respectively. The total electric flux through the shell is -638 N-m/C. What is...
-
Ellipses Corp is a small business that operates in Herndon, VA. The company is located at10 Period Lane, Herndon, VA 20170. Its federal Employer Identification Number is 77-7777777, and its...
-
ALL BEAMS 1.5 I 48 kN 60 kN A I E 21 For the multistory frame shown, use approximate methods to determine the member internal forces and the reactions. Use super position to analyze considering each...
-
Marc and Mikkel are married and earned salaries this year of $ 6 4 , 0 0 0 and $ 1 2 , 0 0 0 , respectively. In addition to their salaries, they received interest of $ 3 5 0 from municipal bonds and...
-
Carson Holiday has a federal tax levy of $ 4 , 1 1 9 . 9 0 against him. If Holiday is single with three dependents and had a take - home pay of $ 1 , 0 2 0 . 0 0 this week, how much would his...
-
At December 3 1 , 2 0 2 3 , Albrecht Corporation had outstanding 3 5 3 , 0 0 0 shares of common stock and 2 0 , 0 0 0 shares of 9 . 5 % , $ 1 50 par value cumulative, nonconvertible preferred stock....
-
Hanna Company s current asset and current liability account balances at the beginning and end of the year were as follows: December 3 1 End of Year Beginning of Year Current assets: Cash and cash...
-
On January 1 , 2 0 2 3 , Ridge Road Company acquired 3 0 percent of the voting shares of Sauk Trail, Incorporated, for $ 4 , 5 0 0 , 0 0 0 in cash. Both companies provide commercial Internet support...
-
Question 2 10 pts You are evaluating a project with an initial investment of $11.9 million dollars, and expected cash flows of $8 million dollars each for years 1-3. What is the project's simple...
-
Frontland Advertising creates, plans, and handles advertising campaigns in a three-state area. Recently, Frontland had to replace an inexperienced office worker in charge of bookkeeping because of...
-
Huey consumes only two goods, X and Y. His indifference curves have the usual shape. He prefers basket (1, 3) to basket (2, 2). a. Is it possible to tell whether Huey prefers (1, 3) to (3, 1)? b. Is...
-
True or False: If all thieves are identical, then the social cost of robbery is equal to the value of the stolen goods.
-
Sam consumes only green eggs and ham. Ham is an inferior good for Sam. One day the price of green eggs goes up. a. Illustrate Sam's old and new optimum points, and show both the substitution and the...
-
Consider a stochastic process such that the underlying security \(S\) follows the model: \[d S_{t}=\mu S_{t} d t+\sigma_{t} S_{t} d Z_{t}\] where \(Z\) is a standard Brownian motion. Suppose the...
-
Calculate the solution to the following SDE: \[d X_{t}=\alpha\left(m-X_{t} ight) d t+\sigma d B_{t}\] with \(X_{0}=x\). The process satisfying this equation is called the meanreverting...
-
Let \(B_{t}\) be a standard Brownian motion started at 0 . Use that for any function \(f\) we have: \[\mathbf{E}\left[f\left(B_{t} ight) ight]=\frac{1}{\sqrt{2 \pi t}} \int_{-\infty}^{\infty} f(x)...
Study smarter with the SolutionInn App