74.2k views
5 votes
Now for the tester class:

j. Create a ComparisonTester class.
k. Add the plumbing.
l. Import Scanne.r
m. Create a Scanner object.
n. Prompt the user to enter two doubles. You will need two variables to receive
the input.
o. Prompt the user to enter two integers. You will need two variables to receive
the input.

p. When we enter numbers and then strings, we run into problems. We need to
clear the buffer. To do that, type in.nextLine();
q. Prompt the user to enter two Strings. You will need two variables to receive
the input.
r. Create a Comparison object.
s. Create a Boolean variable named areTheyEqual. example Boolean
areTheyEqual;
t. Call compFloat2 and assign it to areTheyEqual.
u. Print "The two doubles are equal up to two decimal points: " + areTheyEqual
v. Call compFloat5 and assign it to areTheyEqual.
w. Print "The two doubles are equal up to five decimal points: " + areTheyEqual
x. Call complnt and assign the result to areTheyEqual.
y. Print using the same type of format as above.
z. Call the method stringEqual and assign the result to areTheyEqual.
aa. Print using the same type of format as above.
bb. Call the method stringEqualNoCase and assign the result to areTheyEqual.
cc. Print using the same type of format as above.
dd. Call the method stringCompare and assign the result to areTheyEqual.
ee. Print using the same type of format as above.p. When we enter numbers and then strings, we run into problems. We need to
clear the buffer. To do that, type in.nextLine();
q. Prompt the user to enter two Strings. You will need two variables to receive
the input.
r. Create a Comparison object.
s. Create a Boolean variable named areTheyEqual. example Boolean
areTheyEqual;
t. Call compFloat2 and assign it to areTheyEqual.
u. Print "The two doubles are equal up to two decimal points: " + areTheyEqual
v. Call compFloat5 and assign it to areTheyEqual.
w. Print "The two doubles are equal up to five decimal points: " + areTheyEqual
x. Call complnt and assign the result to areTheyEqual.
y. Print using the same type of format as above.
z. Call the method stringEqual and assign the result to areTheyEqual.
aa. Print using the same type of format as above.
bb. Call the method stringEqualNoCase and assign the result to areTheyEqual.
cc. Print using the same type of format as above.
dd. Call the method stringCompare and assign the result to areTheyEqual.
ee. Print using the same type of format as above.

1 Answer

3 votes

Final answer:

The student query is about creating a ComparisonTester class in Java to compare doubles, integers, and strings using a Comparison object; it includes steps like input handling, object creation, calling methods, and outputting results.

Step-by-step explanation:

The student is asking for guidance on how to create a tester class that compares different types of input using a Comparison object. .

To complete this task, one must:

  1. Create a ComparisonTester class with the necessary setup or 'plumbing'.
  2. Import the Scanner class and create a Scanner object for input.
  3. Prompt the user to enter two doubles and two integers, storing the input in the appropriate variables.
  4. Clear the input buffer with nextLine() to avoid input issues when switching from numbers to strings.
  5. Prompt the user to enter two strings.
  6. Create a Comparison object and a Boolean variable areTheyEqual.
  7. Use the Comparison object to call comparison methods such as compFloat2, compFloat5, complnt, stringEqual, stringEqualNoCase, and stringCompare, and assign the results to areTheyEqual.
  8. Output the results of the comparisons to the user.

User SABU
by
8.2k points