1 import static org.junit. Assert.assertEquals; 2 import org.junit. Test; 3 4 public class CompareNums Test {...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1 import static org.junit. Assert.assertEquals; 2 import org.junit. Test; 3 4 public class CompareNums Test { 5 6 7 8 9 10 // TODO - write your code below this comment. // Write three tests, where each test corresponds to one // of the three possible scenarios: // CompareNums.comparison // - CompareNums.comparison // - CompareNums.comparison - returns "less than" returns "equal to" returns "greater than "L 1 import java.util.Scanner; 2 3 public class Compare Nums { // The method you define will return one of three possible strings: // - "less than": if the first parameter is less than the second 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 N N N N N N N 30 } // - "equal to": if the first parameter is equal to the second // - "greater than": if the first parameter is greater than the second // Make sure you return _exactly the above strings // TODO - write your code below this comment. private static String comparison (int first, int second) { if(first<second) return "less than"; else if(first==second) return "equal to"; return "greater than"; else } L // DO NOT MODIFY main! } public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter first integer: "); int first input.nextInt (); System.out.print("Enter second integer: "); int second = input.nextInt (); System.out.println("The first integer is " + comparison (first, second) + the second integer."); Step 3: Edit CompareNums.java Download the CompareNums. java file, and open it in jGrasp (or a text editor of your choice). You will need to implement a method that returns different Strings, depending on shown below, with user input shown in bold: Enter first integer: 1 Enter second integer: 2 The first integer is less than the second integer. Further example output of the program is shown below, with user input shown in bold: Enter first integer: 1 Enter second integer: 1 The first integer is equal to the second integer. Further example output of the program is shown below, with user input shown in bold: Enter first integer: 2 Enter second integer: 1 The first integer is greater than the second integer. Step 4: Open CompareNums Test.java as a Test File, and Edit It the input values the method receives. You may not modify the code in the main method. Example output of the program is Download the CompareNumsTest.java file, being sure to put it in the same folder/directory as your CompareNums. java file. This file contains a number of tests for the method you wrote in the previous step. Open this file in jGraspa o as a test file, using the same instructions you've used in previous labs. You need to write a number of tests in this file, and all of them must pass. The comments in the file provide more details. 1 import static org.junit. Assert.assertEquals; 2 import org.junit. Test; 3 4 public class CompareNums Test { 5 6 7 8 9 10 // TODO - write your code below this comment. // Write three tests, where each test corresponds to one // of the three possible scenarios: // CompareNums.comparison // - CompareNums.comparison // - CompareNums.comparison - returns "less than" returns "equal to" returns "greater than "L 1 import java.util.Scanner; 2 3 public class Compare Nums { // The method you define will return one of three possible strings: // - "less than": if the first parameter is less than the second 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 N N N N N N N 30 } // - "equal to": if the first parameter is equal to the second // - "greater than": if the first parameter is greater than the second // Make sure you return _exactly the above strings // TODO - write your code below this comment. private static String comparison (int first, int second) { if(first<second) return "less than"; else if(first==second) return "equal to"; return "greater than"; else } L // DO NOT MODIFY main! } public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter first integer: "); int first input.nextInt (); System.out.print("Enter second integer: "); int second = input.nextInt (); System.out.println("The first integer is " + comparison (first, second) + the second integer."); Step 3: Edit CompareNums.java Download the CompareNums. java file, and open it in jGrasp (or a text editor of your choice). You will need to implement a method that returns different Strings, depending on shown below, with user input shown in bold: Enter first integer: 1 Enter second integer: 2 The first integer is less than the second integer. Further example output of the program is shown below, with user input shown in bold: Enter first integer: 1 Enter second integer: 1 The first integer is equal to the second integer. Further example output of the program is shown below, with user input shown in bold: Enter first integer: 2 Enter second integer: 1 The first integer is greater than the second integer. Step 4: Open CompareNums Test.java as a Test File, and Edit It the input values the method receives. You may not modify the code in the main method. Example output of the program is Download the CompareNumsTest.java file, being sure to put it in the same folder/directory as your CompareNums. java file. This file contains a number of tests for the method you wrote in the previous step. Open this file in jGraspa o as a test file, using the same instructions you've used in previous labs. You need to write a number of tests in this file, and all of them must pass. The comments in the file provide more details.
Expert Answer:
Answer rating: 100% (QA)
CompareNumsjava Make comparison method in CompareNums class public so that we can access the method ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
How does the concept of "agency" in socialization, as emphasized by sociologists like Margaret Archer and Anthony Giddens, illuminate individuals' active engagement in shaping their socialization...
-
Given: Beam with distributed and concentrated loadings. Neglect beam self-weight. Find: The reactions at A and B. 1.5 kN/m 1.2 m 3 kN 0.8 m-1 m- B
-
4.22 Consider the left-shift operator on l (N), S : l (N) l (N), S(x1, x2,...) := (x2, x3, . . . ). (i) Show that S is a bounded linear operator. (ii) Show that S is not an isometry. (iii) Find the...
-
Use the test of your choice to determine whether the following series converge. 1 1! + 4 2! + 9 16 + 3! 4!
-
A laser beam strikes one end of a slab of material, as shown in Figure P35.55. The index of refraction of the slab is 1.48. Determine the number of internal reflections of the beam before it emerges...
-
Maddleson Incorporated wants to segregate the fixed and variable portions of maintenance cost, believed to be a semi variable cost, as measured against machine hours. The following information has...
-
Use a dot plot to display the data, which represent the blood glucose levels (in milligrams per deciliter) of 24 patients at a pathology laboratory. Organize the data using the indicated type of...
-
On January 1, 2015, Geffrey Corporation had the following stockholders equity accounts. Common Stock ($20 par value, 60,000 shares issued and outstanding) ...$1,200,000 Paid-in Capital in Excess of...
-
Sharkers Company supplied you with the following information: Share Dividend expected next year (R) Dividend Growth Rate (%) Required Return (%) A 1.10 9 12 B 3.80 6 11 C 0.80 13 17 D 2.60 12 16 E...
-
Which of the following is a positive reason for learning chemistry? (a) Chemistry is relevant to daily life (b) Chemistry offers career opportunities (c) Chemistry studies interesting topics (d)...
-
(a) A company is analyzing the number of accidents that occur each year on the factory floor. It believes that the number of accidents per year N has a geometric distribution with parameter 0.8, so...
-
Posy Corp. acquired treasury shares at an amount greater than their par value, but less than their original issue price. Compared to the cost method of accounting for treasury stock, does the par...
-
The article summarizes the main results of a study on the relationship between Emotional Intelligence and job performance and describes key traits that influence performance. As a project manager,...
-
What is the role of Linux operating system? What are the differences of Windows and Linux? What is a distribution of Linux? What is the Ubuntu operating system? How Linux related to mobile...
-
What is the concept and how is this concept important in your future counseling approach? Discuss and give examples of how you may apply the concept in your counseling? Include a scholarly reference.
-
Your post-secondary institution is facing budget cuts. One of the areas that has been mentioned for a reduction in services is the online writing help (OWH). As a student who has used online writing...
-
Which of the following groups has all proper subgroup that is cyclic ? Z15X217 S3 (Z,+) (Q +)
-
Charles owns an office building and land that are used in his trade or business. The office building and land were acquired in 1978 for $800,000 and $100,000, respectively. During the current year,...
-
Larry Gaines, age 42, sells his personal residence on November 12, 2012, for $144,000. He lived in the house for 7 years. The expenses of the sale are $10,500, and he has made capital improvements of...
-
Emily Jackson (Social Security number 765-12-4326) and James Stewart (Social Security number 466-74-9932) are partners in a partnership that owns and operates a barber shop. The partnership's first...
-
During 2012, William purchases the following capital assets for use in his catering business: New passenger automobile (September 30)........................$21,500 Baking equipment (June 30)...
-
The square plate is deformed into the shape shown by the dashed lines. If DC has a normal strain x = 0.004, DA has a normal strain y = 0.005 and at D, Y xy = 0.02 rad, determine the average normal...
-
The rubber block is fixed along edge AB, and edge CD is moved so that the vertical displacement of any point in the block is given by v(x) = (vo/b 3 )x 3 . Determine the shear strain Y xy = 0.02 at...
-
The square plate ABCD is deformed into the shape shown by the dashed lines. If DC has a normal strain x = 0.004, DA has a normal strain x = 0.005, and at D, Y xy = 0.02 rad, determine the shear...
Study smarter with the SolutionInn App