Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ou are hiking through the rainforests of Central America on a use this trip for exercise as well as finding sloths. Maybe you er, create

image text in transcribed
image text in transcribed
ou are hiking through the rainforests of Central America on a use this trip for exercise as well as finding sloths. Maybe you er, create a new file named HikingForSloths.java sloths, you are very efficient. Hence, you want to can be a role model for the sloths with your pro Your phone has a fitness app eievation as you hike. The elevation data at certain markers aliong installed that keeps track of your the trail can be stored into an array rhic markers might produce an array like this: 57.3 270.0 4.1 528.3 528.3 Each element of the array represents the elevation (in feet above sea level) of that marker on the trail. readData) 1. (10 pts) Within the HikingForsloths class, write the method public static double This method should allow the user to input elevation data into an array. The method should start by user to enter the number of markers. Include error checking to ensure that there must least 1 marker. Then read the user's input for each marker into an array, and return the array that was created. 2. (10 pts) Let's define a peak as a marker whose elevation is greater than the elevation of both adjacent markers. Define a valley as a marker whose elevation is less than the elevation of both adjacent markers. Since these definitions involve both adjacent markers, a peak or valley cannot appear at the beginning or ending of the array. In the array above, 270.0 is a peak since it's higher than both 57.3 and -4.1. -4.1 is a valley since it's lower than both 270.0 and 528.3. There are no other peaks or valleys in the array Let's say a trail is challenging if at least half its markers are peaks or valleys. For example, the trail represented by the array above is not challenging because only 2 out of 5 markers (40%) are peaks or valleys. Within the HikingForsloths class, write the method public static boolean ischallenging(double[] a). This method should return whether or not the trail represented by the array a is challenging. (5 pts) Within the HikingForsloths class, write a main method that calls your readdata and ischallenging methods to determine whether a user-entered trail is challenging. Here's an example of what your program might look like when you run it (underlined parts indicate user input): 3. How many markers are in your data? 0 Must enter at least 1 ma?ker! How many markers are in your data? 5 Enter elevation of marker 1: Enter elevation of marker 2: Enter elevation of marker 3: Enter elevation of marker 4: Enter elevation of marker That trail is not challenging

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

Successful Keyword Searching Initiating Research On Popular Topics Using Electronic Databases

Authors: Randall MacDonald, Susan MacDonald

1st Edition

0313306761, 978-0313306761

More Books

Students also viewed these Databases questions

Question

Are we managing our human capital as a strategic asset?

Answered: 1 week ago