|
|
calculations[8]
, is this the factor to multiply to the Mass for each planet respectively? For example, my mass on Earth is 50kg, so the mass on Mercury is 50kg*1.00 = 50kg?
|
|
//1) Get inputs from user: void userInput(string& PlanetName, string& UserName, double& currentMass) { cout << "Enter the name of the planet: "; cin >> PlanetName; while (PlanetName.compare("Mercury") != 0 && PlanetName.compare("Venus") != 0 && PlanetName.compare("Earth") != 0 && PlanetName.compare("Mars") != 0 && PlanetName.compare("Jupiter") != 0 && PlanetName.compare("Saturn") != 0 && PlanetName.compare("Uranus") != 0 && PlanetName.compare("Neptune") != 0 ) { cout << "Enter the name of the planet: "; cin >> PlanetName; } cout << "Enter your mass: "; cin >> currentMass; cout << "Enter your name: "; cin >> UserName; cout << "----------------------------------------" << endl; } // 2) Do the calculation: double calculateWeight(string PlanetName, double currentMass) { double newMass = 0.00; if (PlanetName == "Mercury") newMass = currentMass*1.00; if (PlanetName == "Venus") newMass = currentMass*0.97; ...... ...... return newMass; } // 3) Output the results and other information void resultOutput(string Name, string Planet, double currentMass, double newMass) { cout << "Name of the User : " << Name << endl; cout << "Planet chose : " << Planet << endl; cout << "Current Mass(kg) : " << currentMass << endl; cout << "New Mass(kg) : " << newMass << endl; } // Main Program int main() { string Name; string Planet; double currentMass = 0.00; double newMass = 0.00; userInput(Planet, Name, currentMass); newMass = calculateWeight(Planet, currentMass); resultOutput(Name, Planet, currentMass, newMass); system("pause"); return 0; } |
|
|
#include <string>
.