How to calculate two no in single line opreation? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to calculate two no in single line opreation?

i want to 10+20 result but i get missmatchexception https://code.sololearn.com/ck5Aqg3ESX7n/?ref=app

7th Mar 2023, 7:13 PM
Nik Shri
Nik Shri - avatar
5 Answers
+ 5
Also try 10 + 20 (spaces between the parts). It works for me.
7th Mar 2023, 11:22 PM
Brian
Brian - avatar
+ 4
You don't enter like this, enter like this:- 10 + 20 Then the output show.
7th Mar 2023, 7:24 PM
Sakshi
Sakshi - avatar
+ 1
but why don't enter like this 10+20...?
8th Mar 2023, 5:08 AM
Nik Shri
Nik Shri - avatar
+ 1
Nik Shri if there are no blank space between, then it is just a single string.
8th Mar 2023, 6:46 AM
Bob_Li
Bob_Li - avatar
+ 1
I would input a string, check what operator has been used and then use the correct output, check out switch case, and comparing chars using String.charAt(position), also you will have convert string numbers to integers.
8th Mar 2023, 4:10 PM
D_Stark
D_Stark - avatar