about | help | code help+videos | done | prefs |
test2025_04_17_HL_baseToDec
Write a method that accepts a string called 'origNum' and a base called 'origBase'. Your goal is to return the value of 'origNum' in base 10. The ONLY string methods you may use are: .length, .charAt, and .equals. You are NOT allowed to use any other classes. As preconditions, you may assume that 'origNum' ONLY contains valid digits in 'origBase'. You may also assume that origBase is between 2 and 36 inclusive. All letters will be capitalized. The only characters in 'origNum' will be 0-9 and A-Z, but ONLY up to the maximum valid digit in 'origBase'. You may also assume that the resulting number in decimal will be less than the maximum positive integer value. Look at the test data for examples. test2025_04_17_HL_baseToDec("B37G", 19) → 76681 test2025_04_17_HL_baseToDec("1111", 5) → 156 test2025_04_17_HL_baseToDec("ABCD", 18) → 62113 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 295
Copyright Nick Parlante 2017 - privacy