Question: You are given a method called int charToInt ( char c ) that will return the integer represented by a single character. E.g. convert ('2')
You are given a method called int charToInt ( char c ) that will return the integer represented by a single character. E.g. convert ('2') returns the integer 2. Write a method called strToDec() that takes a string representation of an integer number and returns the integer. E.g. strToDec("1024") should return the integer 1024. You may only use the String instance methods and charToInt() as explained above. No other method calls are allowed. You may assume no errors, and only positive numbers.
public static int strToDec( String str )
Please don't use scanner()!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
