Question: language is JAVA Objectives In this lab you will practice using for loops with arrays and comparing double values, using a threshold, to see if

 language is JAVA Objectives In this lab you will practice using

language is JAVA

Objectives In this lab you will practice using for loops with arrays and comparing double values, using a threshold, to see if two sets of numbers are the same. Background Reading ZyBooks Chapter 5 Task The first comment of your main method should be your identification comment: .//Lab5b. [Name] You will need to then: Create and populate the two sets of double values, in which the number of elements and the elements themselves are specified by the user. (i.e. the user will state how many numbers are in the first set, give the values for that set and then move on to the second set of numbers). iterate through the sets and compare the values. For the purposes of this lab, we will say that the order matters in determining f the sets are the same. (HINT: This also means that the lengths of the arrays must be the same). If the arrays are the same in both length and values, print set one and set two are equal. Otherwise, print set one and set two are not equal Comparing double values using a threshold Recall that floating-point numbers may differ in a very small value. For example, 1.0 might actually be stored as 0.9999999...or .0000000002. When comparing these values, we often use a "tolerance" level that says, "if the difference is smaller than some amount, then it is negligible and the numbers can be thought of as the same:'We can achieve this by comparing the absolute value of the difference of the elements to the tolerance. For example, if Math.abs( arrayl [0] - array2I0]0.001 System.out.println ("The values of arrayl[0] and array210] are not equal")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!