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 1 meter per 3.2808 feet
In the main function of the main source file, create 7 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 minElevation(const std::vector& mountains){
Mountain min_mountain = mountains[0];
for (const auto& mountain : mountains){
if (mountain.getElevation() min_mountain.getElevation()){
min_mountain = mountain;
}
}
return min_mountain;
}
int main(){
// Create instances of Mountain objects
std::vector mountains ={
Mountain("Chimborazo", "Ecuador", 20549),
Mountain("Matterhorn", "Switzerland", 14692),
Mountain("Olympus", "Greece (Macedonia)",9573),
Mountain("Everest", "Nepal", 29029),
Mountain("Mount Marcy - Adirondacks", "United States", 5344),
Mountain("Mount Mitchell - Blue Ridge", "United States", 6684),
Mountain("Zugspitze", "Switzerland", 9719)
};
// Print the header with column names
std::cout std::left std::setw(40) "Mountain Name"
std::setw(25) "Country"
std::setw(20) "Elevation (ft)"
std::setw(15) "Elevation (m)
"
std::endl;
// Print mountain details
for (const auto& mountain : mountains){
std::cout std::left std::setw(40) mountain.getName()
std::setw(25) mountain.getCountry()
std::setw(20)(std::to_string(mountain.getElevation())+" ft")
std::setw(3) std::fixed std::setprecision(0) mountain.toMeters()" m"
std::endl;
}
// Find and print the shortest mountain
Mountain shortest_mountain = minElevation(mountains);
std::cout "
The mountain with the smallest elevation is: "
shortest_mountain.getName()"," shortest_mountain.getCountry()
", with an elevation (ft) of: " shortest_mountain.getElevation()" ft"
std::endl;
return 0; // Indicate that the program ended successfully
} here the mountain.#include "mountain.h"
Mountain::Mountain(const std::string& name, const std::string& country, int elevation)
: name(name), country(country), elevation(elevation){}
void Mountain::setName(const std::string& name){
this->name = name;
}
void Mountain::setCountry(const std::string& country){
this->country = country;
}
void Mountain::setElevation(int elevation){
this->elevation = 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 /3.2808;
here the mountain.h#ifndef MOUNTAIN_H
#define MOUNTAIN_H
#include
class Mountain {
private:
std::string name;
std::string country;
int elevation; // Elevation in feet
public:
// Constructor
Mountain(const std::string& name, const std::string& country, int elevation);
// Setters
void setName(const std::string& name);
void setCountry(const std::string& country);
void setElevation(int elevation);
// Getters
std::string getName() const;
std::string getCountry() const;
int getElevation() const;
// Function to convert elevation to meters
double toMeters() const;
};
#endif // MOUNTAIN_H 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 directory/folder that the .cpp and .h files)
g++-o 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
 A member function call toMeters that will take the elevation and

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!