Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In Java Please. I keep getting this error. How do i fix it please. Mountain.java: 1 : error: duplicate class: Mountain public class Mountain {
In Java Please. I keep getting this error. How do i fix it please.
Mountain.java:: error: duplicate class: Mountain
public class Mountain
error
import java.util.ArrayList;
import java.util.List;
class Mountain
private String name;
private String country;
private double elevation;
public MountainString name, String country, double elevation
this.name name;
this.country country;
this.elevation elevation;
public String getName
return name;
public String getCountry
return country;
public double getElevation
return elevation;
Define a method to convert the elevation from feet to meters.
public double toMeters
return elevation ;
class Main
public static void mainString args
List mountains new ArrayList;
mountains.addnew MountainChimborazo "Ecuador", ;
mountains.addnew MountainMatterhorn "Switzerland", ;
mountains.addnew MountainOlympus "Greece Macedonia;
mountains.addnew MountainEverest "Nepal", ;
mountains.addnew MountainMount Marcy Adirondacks", "United States", ;
mountains.addnew MountainMount Mitchell Blue Ridge", "United States", ;
mountains.addnew MountainZugspitze "Switzerland", ;
Mountain minElevationMountain minElevationmountains;
System.out.printlnMountaintCountrytElevation fttElevation m;
for Mountain mountain : mountains
System.out.printfststftfn mountain.getName mountain.getCountry mountain.getElevation mountain.toMeters;
System.out.printfnShortest mountain: s with elevation f ft f mn minElevationMountain.getName minElevationMountain.getElevation minElevationMountain.toMeters;
public static Mountain minElevationList mountains
Mountain minElevationMountain mountains.get;
for Mountain mountain : mountains
if mountaingetElevation minElevationMountain.getElevation
minElevationMountain mountain;
return minElevationMountain;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started