Question: 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
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,
withwhat wrong with my code here the main.cpp#include
#include
#include
#include "mountain.h
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
std::endl;
Print mountain details
for const auto& mountain : mountains
std::cout std::left std::setw mountain.getName
std::setw mountain.getCountry
std::setwstd::tostringmountaingetElevation ft
std::setw std::fixed std::setprecision mountain.toMeters m
std::endl;
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
std::endl;
return ; Indicate that the program ended successfully
here the mountain.#include "mountain.h
Mountain::Mountainconst std::string& name, const std::string& country, int elevation
: namename countrycountry elevationelevation
void Mountain::setNameconst std::string& name
thisname name;
void Mountain::setCountryconst std::string& country
thiscountry country;
void Mountain::setElevationint elevation
thiselevation elevation;
std::string Mountain::getName const
return name;
std::string Mountain::getCountry const
return country;
int Mountain::getElevation const
return elevation;
double Mountain::toMeters const
return elevation ;
here the mountain.h#ifndef MOUNTAINH
#define MOUNTAINH
#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;
Setters
void setNameconst std::string& name;
void setCountryconst std::string& country;
void setElevationint elevation;
Getters
std::string getName const;
std::string getCountry const;
int getElevation const;
Function to convert elevation to meters
double toMeters const;
;
#endif MOUNTAINH but i keep getting the wront output can i please get the right one for zybook in c please Instructor note:
If you are developing on an external environment, note that this is a multi file project. In order to compile and link this program, you
could use the command in the same directoryfolder that the cpp and h files
go main cpp
Notes are given for which parts you will need to pay attention to
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 convert
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
