I'm trying to make my program output what your weight would be on a plant or the moon depending on what letter the user inputs. So far it's not working, if i use int values it works fine but as soon as i try using char values it won't work.I really need help on this.
heres the program
#include <iostream> //Header
const double e = 0.8975; //Venus coefficient
const double a = 1.0; //Earth coefficient
const double o = 0.166; //Moon coefficient
const double u = 2.5374; //Jupiter coefficient
const double t = 1.0677; //Saturn coefficient
cout << "please enter your weight" << endl << endl;
cin >> weight;
cout << "Now please enter one of the numbers that corresponds" << endl;
cout << "to one of the following plants or moon:" <<endl << endl;
cout << "Venus=1, Earth=2, Moon=3, Jupiter=4, Saturn=5."<<endl << endl;
cin >> plantLet;
This is comparing your variable plantLet to a variable named V. You never gave V a value, so this is meaningless. Just because you named the variable V does not mean it represents the character V. You could just as easily name it WorchestershireSauce -- the names of variables do not matter.
If you want to compare against the actual letter 'V', then you need to use a character literal, not a variable. Do this by putting the character inside single quotes:
1 2 3
// char V; // <- get rid of all of these
if(plantLet == 'V') // use 'V', not V. Also I don't know why you had <=
if (plantLet!= V && E && M && J && S)
This code does not do what you expect. There is no need for it anyway, since the 'else' chain ensures that plantLet is not any one of the previously checked options.