Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is java and please must follow the instruction and must put //(comment) and make simple program. Thank you a) Create a Bug class b)

This is java and please must follow the instruction and must put //(comment) and make simple program. Thank you

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 method

i) Create a Bug object with 10 as the argument

j) In a loop, breed the bugs 4 times.

k) In a loop, spray the bugs 4 times.

l) Print the result.

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

Beyond Greed And Fear Understanding Behavioral Finance And The Psychology Of Investing

Authors: Hersh Shefrin

1st Edition

0195161211, 978-0195161212

Students also viewed these Databases questions