My problem is simple. How can I go about making the value a represent the letter a. I need to make it so someone can type 'a' into the program and have it trigger my script for addition.
#include <iostream>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <istream>
usingnamespace std;
int main()
{
{
char a,s,x,r,p,d;
a = "a";
cout << "Enter 'a' for Addition" << endl << "Enter 's' for Subtraction" << endl;
cout << "Enter 'x' for Multiplication" << endl << "Enter 'd' for Division" << endl;
cout << "Enter 'p' for Powers" << "Enter 'r' for Square Root" << endl;
cout << "Please disragard the quotes" << endl;
{
if
(a == "a")
{
float w, b, c,;
c = w + b;
cout << "Please enter the first number" << endl;
cin >> w;
cout << "Please enter the second number" << endl;
cin >> b;
cout << c << endl;
system("PAUSE");
}
}
That's not the whole thing, so keep in mind its missing some things.
So basically, how do I go about making my char a to equal a on the keyboard, and ect for s,x,r,p,d?
Thank you. That fixed my issue. I have a new problem though. For some reason the answer to my equation is coming out as a weird number every time.I tried making w, b, c, doubles and integers, but its not coming out right. It's doing the same with my other equations (subtraction, multiplication...ect). Any idea?
EDIT: Nevermind. All I had to do was switch c = w + b; and put it AFTER the cin commands. Thanks again.