Question
Question 1: Implement a class Product. A product has a name and a price, for example new Product(Toaster, 29.95). Supply methods getName(), getPrice(), and setPrice().
Question 1:
Implement a class Product. A product has a name and a price, for example new Product("Toaster", 29.95). Supply methods getName(), getPrice(), and setPrice(). Write in a program that makes two products, prints the name and price, reduces their prices by $5.00, and then prints them again.
Question 2:
Implement a class RoachPopulation that simulates the growth of a roach population. The constructor takes the size of the initial roach population. The waitForDoubling method simulates a period in which the population doubles. The spray method simulates spraying with insecticide, which reduces the population by 10%. The getRoaches method returns the current number of roaches. Implement the class and a test program that simulates a kitchen that starts out with 10 roaches. Wait, spray, print the roach count. Repeat three times.
please send me this in java programming using netbeans
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started