Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Note: Make sure that you put the header comments in this main.cpp and all other cpp files file. Note: Make sure that you put the
Note: Make sure that you put the header comments in this main.cpp and all other cpp files file. Note: Make sure that you put the header comments in this main.cpp and all other cpp files file.The following data will be used for this project
Write a program that will include the following:
A class that will store mountain details which will included the following:
List item
Member for the name, make it private
Member for the country, make it private
Member for the elevation, make it private
Setters and getters for all the data members. Make them public
A member function call toMeters that will take the elevation and convert the value from feet to meters and return the converted
value. The relationship for feet to meters is meter per feet
In the main function of the main source file, create instances of Mountain objects and put the mountain data from the table
above.
Put the mountain objects in an appropriate data structure for the language that you are writing this for.
Write a method called minElevation that will return the minimum elevation.
Iterate over the data structure that contains the Mountain objects and print out the Mountain details similar to the table above,
with the addition of the elevation in feet and in meters.
Programmatically print out the elevation and name of the shortest mountain do not hard code this
The output for this program should be the following#include
#include
#include
#include
class Mountain
private:
std::string name;
std::string country;
int elevation; Elevation in feet
public:
Constructor
Mountainconst std::string& name, const std::string& country, int elevation
: namename countrycountry elevationelevation
Setters
void setNameconst std::string& name
thisname name;
void setCountryconst std::string& country
thiscountry country;
void setElevationint elevation
thiselevation elevation;
Getters
std::string getName const
return name;
std::string getCountry const
return country;
int getElevation const
return elevation;
Function to convert elevation to meters
double toMeters const
return elevation ;
;
Function to find the mountain with the minimum elevation
Mountain minElevationconst std::vector& mountains
Mountain minmountain mountains;
for const auto& mountain : mountains
if mountaingetElevation minmountain.getElevation
minmountain mountain;
return minmountain;
int main
Create instances of Mountain objects
std::vector mountains
MountainChimborazo "Ecuador",
MountainMatterhorn "Switzerland",
MountainOlympus "Greece Macedonia
MountainEverest "Nepal",
MountainMount Marcy Adirondacks", "United States",
MountainMount Mitchell Blue Ridge", "United States",
MountainZugspitze "Switzerland",
;
Print the header with column names
std::cout std::left std::setw "Mountain Name"
std::setw "Country"
std::setw "Elevation ft
std::setw "Elevation m
;
Print mountain details
for const auto& mountain : mountains
std::cout std::left std::setw mountain.getName
std::setw mountain.getCountry
std::setw mountain.getElevation ft
std::setw staticcastmountaintoMeters m
;
Find and print the shortest mountain
Mountain shortestmountain minElevationmountains;
std::cout
The mountain with the smallest elevation is:
shortestmountain.getName shortestmountain.getCountry
with an elevation ft of: shortestmountain.getElevation ft
;
return ; Indicate that the program ended successfully
can u please fix my code so it can make up to this
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