the exception you are getting is beacuse you passed '0.0C' to the float parser at:
tempValue = Float.parseFloat(args[1].substring(0, scaleIndex));
that is beacuse you do
scaleIndex = args[1].indexOf('F');
effectively overwriting the scaleIndex instead of setting scaleIndex2
please be open minded with my following recommendations:
- object oriented means you create classes which will take up responsibility
- your Temperature class stores temp in celsius and in fahrenheit too..which might be easier, but storing only for example Kelvins would mean you have a strong inner concept inside the class
- when someone asks for C or F it calculates from the K
- after that the Temperature class's constructor should be responsible for parsing '0.0C' and '42.0F'