Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Someone help me with this please! Suppose you have one cent ($0.01) in a sock. E

ID: 3924206 • Letter: S

Question

Someone help me with this please!

Suppose you have one cent ($0.01) in a sock. Each day you double the amount of money you have in the sock. Thus on day one you have one cent, on day two you have two cents ($0.02), on day three you have four cents ($0.04), and so forth.

The doubleEachDay method takes a double value, jackpot, as its input argument, and calculates the number of days needed to reach or exceed the jackpot amount, starting at 0.01 and doubling each day. The method returns the number of days required for doubling; this value should be stored in the integer variable numDays.

Finish the doubleEachDay method below.

public int doubleEachDay(double jackpot) {
  double amount = 0.01;
  int numDays = 0;


  return numDays;
} //end method

Explanation / Answer

public int doubleEachDay(double jackpot)

{

double amount=0.01;

int numDays=0;

while(amount<jackpot)

{

amount=amount*2.0;

numDays++;

}

return numDays;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote