typedef oldtype newtype;
| Planet Name | Factor |
|---|---|
| Mercury | 0.4155 |
| Venus | 0.8975 |
| Earth | 1.0 |
| Moon | 0.166 |
| Mars | 0.3507 |
| Jupiter | 2.5374 |
| Saturn | 1.0677 |
| Uranus | 0.8947 |
| Neptune | 1.1794 |
| Pluto | 0.0899 |
main:
GetPlanetName
GetWeight
CalculateWeightOnPlanet
PrintResults
GetPlanetName
do
Prompt
Get value from user
while ValidPlanet != none
return planet
ValidatePlanet
// input: a string, the name of the planet
// output: some type of variable
change planet name to all lower case.
if the planet is in the table, return the plant
// this will need to be a if-else if ...
else return none
CalculateWeightOnPlanet
// input a valid planet
// a valid weight on Earth
// Output the weight on the other plannet.
Get Conversion Factor (based on planet)
Perform Multiplication
Return value
using namespace std; const int NONE = 0; const int MERCURY = 1; const int VENUS = 2; ...
const int SATURN = 5; const int URANUS = 5; ...
enum PlanetT {NO_PLANET, MERCURY, VENUS, EARTH, MOON,
MARS, JUPITER, SATURN, URANUS, NEPTUNE, PLUTO}
PlanetT ValidatePlanet(string planetName);
float CalculateWeight(PlanetT destinationPlanet, float weightOnEarth);
...
int main() {
PlanetT destination = NO_PLANET;
}