+ 1
How do you read arithmetic symbols using char
I'm trying to program a simple calculator
5 odpowiedzi
+ 3
read the whole input as a string perhaps?
if you are wanting the user to input a whole expression that is how I would approach it (i.e user input: 6 * 6 =)
+ 3
you could seperate the inputs and have the program store the symbol seperate to the numbers.
i.e
ask user for number. store as double/float
ask user for symbol. store as char/string
ask user for another number: store as double/ float.
then you could use if/else statements to select the correct symbol and perform the calculation on the numbers
+ 1
I see that makes sense but what if I want to use if statements?
+ 1
yeah I did but my Problem is that you see when getting data from the user using the scanner I don't know what to use to assign the data to symbol/operator
if wanted an integer from the user I would say num1 = console.nextInt()
what do I write for
char?