I'm a little stuck and looking for a little help.
For a class assignment, I have a dialogue box input for a simple calculator. eg 5*8
I'm casting the 5 and 8 to double and the "*" to a char.
I get an error when putting the char into a calculation and I'm not sure how else to do it.
The error is on x in the compute variable. Anyone know a work around for this?Code:
// Convert numOne from a string to double
double doub_numOne = Double.parseDouble(numOne);
// Convert operand from a string to a char
int ascii = operand.charAt(0);
char x = (char)ascii;
// Convert numTwo from a string to double
double doub_numTwo = Double.parseDouble(numTwo);
// Perform the computation
double compute = (doub_numOne x doub_numTwo);
// Output to the screen
System.out.printf("%.02f %c %.02f = %.02f", doub_numOne, x, doub_numTwo, compute);