Question: IN JAVA PLEASE 6.8 PRACTICE: Loops*: Biggest difference Write a program that outputs the biggest difference (absolute value) between any successive pair of numbers in

IN JAVA PLEASE IN JAVA PLEASE 6.8 PRACTICE: Loops*: Biggest difference Write a program that

6.8 PRACTICE: Loops*: Biggest difference Write a program that outputs the biggest difference (absolute value) between any successive pair of numbers in a list. Such a list might represent daily stock market prices or daily temperatures, so the difference represents the biggest single-day change. The input is the list. size, followed by the numbers. If the input is 56063686159 , the output is 7. Hints: - Declare a variable for the current number, and another for the previous number. At the start of each loop iteration, set prevNum : currNum, then get the next number into currNum. - Maintain a max difference variable. Initialize it with . In each loop iteration, check if the difference between currNum and prevNum exceeds maxDiff, if so, update maxDiff with that difference. - Don't forget to take the absolute value of the difference before the above comparison. - Dont try to check the max difference for the first number in the list, since no previous number exists

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!