Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write in Java Write in Java Write in Java Problem 1 - Name your class HikingFors

ID: 3705413 • Letter: W

Question

Write in Java
Write in Java
Write in Java

Problem 1 - Name your class HikingForstoths You are hiking through the ainforests of Central for sloths. Unlike sloths, you are a want to use this trip for exercise as well as findiny you can be a role model for the sloths with your America on a quest efficient person tence, yo Your phone has a fitness app installed that kees elevation as you hike. As you pass certan app a track of your this elevation data t e a on the tras example, a trail with five markers might maticall ystores this elevation data into an array produce an array like this: 57.3 270.0 528.3 143.8 element of the array represents the elevation (in feet above level) of that marker on the trail. 1. (6 pts) A trail is considered "low altitude" if at leaste onsidered low aitude that takes a Da lower. The trail represented by the array above would be its markers have an elevation of 200 ft or lower altitude. as a parameter and returns whether that trail islow t (11 pts) Write a method method should phowTrailData that takes a ID array of double values as a parameter. The t the elevations on the trail. Each elevation should be separated from the next by one of these characters: it the trail stays at the same elevation going to the next marker if the trail loses elevation going to the next marker if the trail gains elevation going to the next marker For example, calling your method with the array above as the argument should print 57.3 27.0 4.1/528.3 I 143.8 Since the backslash is an escape character, use?" within a string to show the backslash character itself. 3 pts) Write a main method that creates an array with the data from the example above, then calls both of your methods and shows the results. You do not need to read any user input

Explanation / Answer

HikingForSloths.java

package HikingForSloths;

public class HikingForSloths {

public static void main(String[] args) {
  
double elevation_data[] = {57.3,270.0,-4.1,528.3,143.8};
  
isLowAltitude(elevation_data);
showTrailData(elevation_data);
  
}
  
public static void isLowAltitude(double[] elevation_data)
{
int low_altitude_count=0;
double low_altitude_percent_count;
  
for(int i=0;i<5;i++)
{
if(elevation_data[i]<=200)
{
low_altitude_count++;
}
}
  
low_altitude_percent_count = ((double)low_altitude_count/(double)5) * 100;
  
if(low_altitude_percent_count>=60)
{
System.out.println("The trail is low attitude");
}
else
{
System.out.println("The trail is high altitude");
}
  
}
  
public static void showTrailData(double[] elevation_data)
{
for(int i=0;i<5;i++)
{
System.out.print(elevation_data[i]);
if(i<=3)
{
if(elevation_data[i]==elevation_data[i+1])
{
System.out.print("-");
}
else if(elevation_data[i]>=elevation_data[i+1])
{
System.out.print("\");
}
else
{
System.out.print("/");
}
}
}
}
  
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote