I need to rewrite the following program so it uses an enumerated type to represent the planet.
[code]
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
double weight;
int planetNumber;
double weightOnPlanet;
double planetFactor;
string planetName;
cout << "Planet names: \n1. Mercury \n2. Venus \n3. Earth \n4. Moon \n5. Mars \n6. Jupiter \n7. Saturn \n8. Uranus \n9. Neptune \n10. Pluto" << endl;
cout << "Please enter your weight and planet number:";
cin >> weight >> planetNumber;
cout << endl;
switch (planetNumber)
{
case 1:
planetName = "Mercury";
planetFactor = 0.4155;
break;
case 2:
planetName = "Venus";
planetFactor = 0.8975;
break;
case 3:
planetName = "Earth";
planetFactor = 1.0;
break;
case 4:
planetName = "Moon";
planetFactor = 0.166;
break;
case 5:
planetName = "Mars";
planetFactor = 0.3507;
break;
case 6:
planetName = "Jupiter";
planetFactor = 2.5374;
break;
case 7:
planetName = "Saturn";
planetFactor = 1.0677;
break;
case 8:
planetName = "Uranus";
planetFactor = 0.8947;
break;
case 9:
planetName = "Neptune";
planetFactor = 1.1794;
break;
case 10:
planetName = "Pluto";
planetFactor = 0.0899;
break;
defaut:
cout << "You have entered a wrong planet name" << endl;
system ("pause");
return 0;
}
weightOnPlanet = weight * planetFactor;
cout << setw(11) << "PlanetName" << setw(15) <<
"PlanetFactor" << setw(20) << "WeightOnThePlanet" <<
endl;
cout << "---------------------------------------------------" << endl;
cout << setw(8) << planetName << setw(15) <<
planetFactor << setw(15) << weightOnPlanet << endl;
system ("pause");
return 0;
}
I am not sure if I understand how and where to put this code in program