Question: How do I write the code for this CodeHS assignment? Use the pictures provided. Assig nme nt W Status: Not Submitted [3' A biology teacher
How do I write the code for this CodeHS assignment? Use the pictures provided.


Assig nme nt W Status: Not Submitted [3' A biology teacher asked her class to answer the following question: If I put 7 bacteria on the classroom doorknob tonight, how many bacteria will be 0 n the doorknob by the time we come to school tomorrow? In order to answer this question, you need to know a few things: 1. Each bacterium (a single bacteria] can create 4 more bacteria every hour 2. This means that after one hour, the doorknob will have 7 + 7 * 4 = 35 bacteria, since we started with 7 bacteria and each of those created 4 more. 3. This means that after two hours, the doorknob will have 35 + 35 * 4 = 175, since there were 35 bacteria at the beginning of hour two, and during that hour each bacteria created 4 more bacteria. 4. Continuing this pattern, the number of bacteria on the doorknob after N hours is numberOfBacteriaLastHour + numberOfBacteriaLastHour * 4 5. However, if we wanted to know how many bacteria are alive after 12 hours, we need to know how many bacteria were alive at hour 11. To nd out how many bacteria are alive at hour 11, we need to gure out how many were alive at hour 10. Do you see how we can use recursion to solve this problem? Write a recursive function that computes the number of bacteria alive after N hours. The function signature is public static int colonySizeCint hour) 10.1.9 Bacteria Cultures Submit + Continue Save Bacteria.java 1 - import java.util. Scanner; 2 public class Bacteria 3 . { 4 public static void main(String args) 5 6 Scanner input = new Scanner(System. in); 7 8 System. out. printIn("How many hours will the bacteria sit? "); 9 int hours = input . nextInt(); 10 int bacteria = numBacteriaAlive(hours); 11 System. out. printIn("After " + hours + ", there will be " + bacteria); 12 13 public static int numBacteriaAlive(int hour) 14- 15 - if (hour == 0) { 16 return 10; 17 } 18 - else { 19 return numBacteriaAlive(hour - 1) * 3; 20 21 22 13 10.2 10.3 10.4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
