This is probably just a stupid mistake that I made that I don't know how to fix...it says this about 'X' and 'operation'...any help would be appreciated thanks.
heres the code:
#include <iostream>
#include <cmath>
usingnamespace std;
void main() {
double number, number1, sum = 0.0, sum1 = 0.0;
char X, operation;
while (operation != 'X')
{
cout<<"Enter the operation you wish to compute:\n+ for addition\n- for subtraction\n^ to raise a number to a power\ns for square root\n* for multiplication\n/ for division\nenter 'X' to exit the program\n";
cin>>operation;
switch (operation)
{
case'+': cout<<"Enter the number you wish to add, enter 'X' to finish: ";
cin>>number;
while (number=X) {
break;
}
while (number != X) {
sum = sum1 + number;
cout<<"Enter the number you wish to add, enter 'X' to finish: ";
cin>>number;
}
cout<<"The sum of the numbers you entered is "<<sum<<".\n";
break;
case'-': cout<<"Enter the number you wish to subtract from, enter 'X' to finish: ";
cin>>number1;
while (number != X) {
sum = number1-number;
cout<<"Enter the number you wish to subtract, enter 'X' to finish: ";
cin>>number;
}
cout<<"The difference of the numbers you entered is "<<sum<<".\n";
break;
case'*': cout<<"Enter the number you wish to multiply, enter 'X' to finish: ";
cin>>number1;
while (number!= X) {
sum= number1*number;
cout<<"Enter the number you wish to multiply, enter 'X' to finish: ";
cin>>number;
}
cout<<"The product of the numbers you entered is "<<sum<<".\n";
break;
case'/': cout<<"Enter the number you wish to divide, enter 'X' to finish: ";
cin>>number1;
while (number!= X && number1!= X && number!=0) {
sum=number1/number;
cout<<"Enter the number you wish to divide by, enter 'X' to finish: ";
cin>>number;
}
cout<<"The quotient of the numbers you entered is "<<sum<<".\n";
break;
case'^': cout<<"Enter the number you wish to raise to a power, enter 'X' to finish: ";
cin>>number1;
while (number1!= X && number!= X) {
sum= pow(number1, number);
cout<<"Enter the power you wish to raise the value to, enter 'X' to finish: ";
cin>>number;
}
cout<<"The value of "<<number1<<"to the "<<number<<" is "<<sum<<".\n";
break;
case's':
case'S': cout<<"Enter the number you wish to take the square root of, enter 'X' to finish: ";
cin>>number;
while (number!= X) {
sum= sqrt(number);
}
cout<<"The square root of "<<number<<" is "<<sum<<".\n";
break;
case'x':
case'X': break;
default: cout<<"Are you sure this is what you want to do?";
break;
}
}
}
This program is supposed to compute basic calculator functions and I am realizing more and more as I get it closer to running that it has many more issues than just the 2 i posted about... the problem with 'X' i have already solved