Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can somebody convert this to if-else statements instead of using case public static int hexToBase10(String x) { int finresult = 0; for (int i =
Can somebody convert this to if-else statements instead of using case
public static int hexToBase10(String x) {
int finresult = 0;
for (int i = 0; i < x.length(); i++) {
//get a character at given index.
switch (x.charAt(i))
{
case '0':
break;
case '1':
finresult += (int)(Math.pow(16, x.length() - i - 1) + 0.5);
case '2':
finresult += 2 *(int)(Math.pow(16, x.length() - i - 1) + 0.5);
case '3':
finresult += 3 *(int)(Math.pow(16, x.length() - i - 1) + 0.5);
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started