#include #include #include #include #include #include "cgi.h" using namespace std; int main() { cout << "Content-type: text/html\n\n" << "\n" << "\n" << "\n" << "Travelling...\n" << "\n" << "\n" << "\n" << "\n" << "

Calculate Your Weight on Different Planets

\n"; const cgi c; const map& m {c.get_input()}; double weight {0.0}; auto it {m.find("weight")}; if (it == end(m)) { cout << "
Could not get mass<\n"; } else if (it->second == "") { weight = 0.0; } else { weight = stod(it->second); } if (weight <= 0.0) { cout << "
Mass must be positive.\n"; } int planet {0}; auto itt {m.find("planet")}; if (itt == end(m)) { cout << "
Could not get planet. I don't remember putting Pluto here.\n"; } else { planet = stoi(itt->second); } struct body { string name; double gravity; }; const vector aduetog { {"", 0.0}, {"Mercury", 0.38}, {"Venus", 0.91}, {"Earth", 1.00}, {"Mars", 0.38}, {"Jupiter", 2.34}, {"Saturn", 1.06}, {"Uranus", 0.92}, {"Neptune", 1.19} }; if (planet < 1 || planet > 8) { cout << "
Could not get planet in our current solar system.\n"; } else { const body& b {aduetog[planet]}; const double weightcalc {weight * b.gravity}; cout << "
Your weight on " << b.name << " is " << weightcalc << " pounds.\n"; } cout << "\n" "\n"; return EXIT_SUCCESS; }