Answered step by step
Verified Expert Solution
Question
1 Approved Answer
a) Translate the method below to use a while loop instead of a for loop. public static String remove Numbers (String source) { String
a) Translate the method below to use a while loop instead of a for loop. public static String remove Numbers (String source) { String result = ""; // have to start with an empty string to keep Java happy for (int index = 0; index < source.length(); ++index) { char letter = source.charAt(index); if (!Character.isDigit (letter)) // look it up in the API result letter; } return result; } b) Rewrite the method below so the while loop is replaced by a for loop. The initialization, test, and increment in the for loop must be non-empty. public static int sumOfFibonaccis(int end) { if (end < 2) return end; int sum = 1; // this is the sum of the first two elements int previousprevious = 0; int previous = int index = 2; 1; while (index < end) { } } int next previous + previousprevious; = sum sum + previous + next;B previousprevious = previous; previousnext; index = index + 1; return sum;
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