Expand|Select|Wrap|Line Numbers
- #include "stdafx.h"
- #include <iostream>
- #include <cstdlib>
- #include <string>
- using namespace std;
- int main() {
- int weight;
- string planet;
- double Mercury_Factor = 0.4155;
- double Venus_Factor = 0.8975;
- double Earth_Factor = 1.0;
- double Mars_Factor = 0.3507;
- double Jupiter_Factor = 2.5374;
- double Saturn_Factor = 1.0677;
- double Uranus_Factor = 0.8947;
- double Neptune_Factor = 1.1794;
- double Pluto_Factor = 0.0899;
- double weightOnPlanet;
- cout << "Assignment 5" << endl;
- cout << "The program is written by Daron Seals" << endl;
- cout << "\n";
- cout << "Please Enter Weight (as an integer of pounds): ";
- cin >> weight;
- cout << "Please Enter Planet name (ie: Earth): ";
- cin >> planet;
- cout << "\n";
- cout << "You entered a weight of" << " " << weight << " " << "and a planet name of" << " " << planet << endl;
- if (planet == "Mercury")
- weightOnPlanet = weight * Mercury_Factor;
- else
- if (planet == "Venus")
- weightOnPlanet = weight * Venus_Factor;
- else
- if (planet == "Earth")
- weightOnPlanet = weight * Earth_Factor;
- else
- if (planet == "Mars")
- weightOnPlanet = weight * Mars_Factor;
- else
- if (planet == "Jupiter")
- weightOnPlanet = weight * Jupiter_Factor;
- else
- if (planet == "Saturn")
- weightOnPlanet = weight * Saturn_Factor;
- else
- if (planet == "Uranus")
- weightOnPlanet = weight * Uranus_Factor;
- else
- if (planet == "Neptune")
- weightOnPlanet = weight * Neptune_Factor;
- else
- if (planet == "Pluto")
- weightOnPlanet = weight * Pluto_Factor;
- if (planet != "Mercury" && planet != "Venus" && planet != "Earth" && planet != "Mars" &&
- planet != "Jupiter" && planet != "Saturn" && planet != "Uranus" && planet != "Pluto" && planet != "Neptune" &&
- planet != "Pluto")
- cerr << "Unknown Planet\n";
- cout << "On" << " " << planet << " " << "your weight in pounds would be" << " " << weightOnPlanet << endl;
- system("pause");
- return 0;
- }