Question: This program will simulate the growth and decrease of bugs based on breeding the bugs and spraying the bugs. a. Create a Bug class b.

This program will simulate the growth and decrease of bugs based on breeding the bugs and spraying the bugs.

a. Create a Bug class

b. Create an instance variable to hold the number of bugs.

c. Create a constructor that sets the original number of bugs to an amount that is provided through the argument. Hint: BankAccount with an initial balance.

d. Create a method call breedBugs. This method will not return anything and will not have an argument. The breedBugs method should double the number of bugs each time it is invoked or called

e. Create a method called sprayBugs. This method will not return anything and will not have an argument. The sprayBugs should decrease the number of bugs by 1/4 each time it is invoked. Multiply the total bugs by .75. Your bugs should be integers because you do not have partial bugs. However, because we are dividing your result may be a double. To take care of this problem, put (int)(your formula) in your method. This is a cast. Be sure and put your formula in ().

f. Create a method to return the number of bugs.

g. Create a BugTester class

h. Create a main

i. Create a Bug object and begin with 10 bugs. Hint: Remember how you created a BankAccount Object with an initial balance.

j. Call / invoke the breedBugs method . Hint: Call deposit but no parameters.

k. Call the sprayBugs method 3 .

l. Print the number of bugs (The result should be an integer no half dead bugs)

m. Repeat j l two additional times. This means that you will breed, spray and print 3 times.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!