Answered step by step
Verified Expert Solution
Link Copied!

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

image

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Prelude To Programming

Authors: Stewart Venit, Elizabeth Drake

6th Edition

013374163X, 978-0133741636

More Books

Students also viewed these Programming questions

Question

please do number 4 journal entires transaction 2 and transaction 5

Answered: 1 week ago

Question

A personal computers main circuit board is called its ____________.

Answered: 1 week ago

Question

A database consists of many tables. True or False

Answered: 1 week ago