how do I let a user input a "*" and enter it into a case? | Sololearn: Learn to code for FREE!


how do I let a user input a "*" and enter it into a case?

so im trying to make a calculator where the user can input an equation and choose the type (+,-,*,/) but i cant seem to figure out how to do it any ideas?

5/19/2022 9:53:12 PM

Nikos Garcia

11 Answers

New Answer


Nikos Garcia You can take character (+, -, *, /) input and apply in switch statement like this: Scanner sc = new Scanner (; char c =; System.out.println (c); switch (c) { case '+': System.out.println ("add"); break; }


Nikos Garcia input your operator as a string or char. Then use a Switch to create the associated operation


The¥AIRWeb He asked how to take * as an input. What you didn't understand here? Simply he wants to make a calculator and taking +, -, *, / as an input and want to put this in switch case. I don't think it's a meaningless question. Everyone understood question except you only.


What is your code?


Share your code Nikos Garcia


The¥AIRWeb Why are you posting unnecessary comments?


It's on the tag Great