You have defined the method number()
which takes a String, and returns a double. The type of Strings it supports are like “one”, “two” and so on, not “1”, “2”...
You have said that you tried the input add 50 34
, and based on your code, this is going to always return 0.0
Try providing the input add five three
and see what output you get.
Your current code will not support a calculation where the input is more than 9. And the user has to provide the value in words, so they can’t type 9, they have to type the word ‘nine’.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…