I'm learning C++ and I've gone through some lessons and now I was doing this assignment, but I can't get it to work in the currently written code.
This the code:
int main() {
double weight;
char planets;
std::cout << "Please enter your current earth weight: ";
std::cin >> weight;
std::cout << "Which planet would you like to go?\n";
std::cout << "Mercury,Venus,Mars,Jupiter,Saturn,Uranus,Neptune \n";
std::cout << "Which planet are you visiting? \n";
std::cin >> planets;
if (planets == Mercury) {
weight = weight * 0.38;
}
else if (planets == Venus) {
weight = weight * 0.91;
}
else if (planets == Mars) {
weight = weight * 0.38;
}
else if (planets == Jupiter) {
weight = weight * 2.34;
}
else if (planets== Saturn) {
weight = weight * 1.06;
}
else if (planets == Uranus) {
weight = weight * 0.92;
}
else if (planets == Neptune) {
weight = weight * 1.19;
}
std::cout << "Ti do ishe " << weight << "\n";
}
When I change the variable to int x;
and afterward replace the input data with numbers, it works but as I said I want it to work by using names.
What's wrong?