Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

must be in java In this problem, we are going to compare some values. We will examine the difference between comparing integers, doubles, and words.

must be in java

In this problem, we are going to compare some values. We will examine the difference between comparing integers, doubles, and words.

Create a class named Comparison.

Do no create instance variables.

Do not create a constructor.

Write a method called compFloat2 which accepts as input two doubles as an argument (parameter). Write the appropriate code to test the two numbers up to two decimal points to see if they are close enough. If they are close enough return true else return false. This would be a Boolean value.

Write a method called compFloat5 which accepts as input two doubles as an argument (parameter). Write the appropriate code to test the two numbers up to five decimal points to see if they are close enough. If they are close enough return true else return false. This would be a Boolean value.

Write a method called compInt which accepts as input two integers as an argument (parameter). Write the appropriate code to test the two integers to see if they are equal. If they are equal return true else return false. This would be a Boolean value.

Write a method called stringEqual program that reads in two sentences as an argument (parameter). Write the appropriate code to test the two strings to see if they are the equal. If they are equal return true else return false. This would be a Boolean value.

Write a method called stringCompare program that reads in two sentences as an argument (parameter). Write the appropriate code to test the two strings to see if string 1 is greater than string 2. If they are return true else return false. This would be a Boolean value.

Now for the tester class:

Create a ComparisonTester class.

Import Scanner

Create a Scanner object.

Prompt the user to enter two doubles. You will need two variables to receive the input.

Create a Comparison object.

Create a Boolean variable named areTheyEqual. Boolean areTheyEqual;

Call compFloat2 and assign it to areTheyEqual.

Print The two doubles are equal up to two decimal points: areTheyEqual

Call compFloat5 and assign it to areTheyEqual.

Print The two doubles are equal up to five decimal points: areTheyEqual

Prompt the user to enter two integers. You will need two variables to receive the input.

Call compInt and assign the result to areTheyEqual.

Print using the same type of format as above.

Prompt the user to enter two Strings. You will need two variables to receive the input. These should be allowed to have spaces and therefore you need to use nextLine(). If you use that you will have an issue so do it this way. S1= in.nextLine(); in.nextLine(); s2 = in.nextLine().

Call stringEqual and assign the result to areTheyEqual.

Print using the same type of format as above.

Call stringCompare and assign the result to areTheyEqual.

Print using the same type of format as above.

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

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

More Books

Students also viewed these Databases questions

Question

3. What are potential solutions?

Answered: 1 week ago