Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q. Write a Java Progr A chickens farmer receives from a supplier young chicken that he raises until they have the weight needed for

Q. Write a Java Progr A chickens farmer receives from a supplier young chicken that he raises until they have

Q. Write a Java Progr A chickens farmer receives from a supplier young chicken that he raises until they have the weight needed for marketing. A chicken is characterized by its weight and an identification number. The price of a chicken varies according to the price of the day and the weight. Suppose that the price of the day is 5 riyals per kilo. So, for a chicken with a weight of 3.4 kilograms the price will be 17 riyals. The price of the day (dailyPrice) and the necessary weight to market a chicken (necessary Weight) are the same for all chickens. By default, dailyPrice = 8 and necessary Weight=1.5 Write the Chicken class according to the class diagram below: Chicken 1-static double dailyPrice -static double necessaryWeight -double weight -int id +Chicken(int id, double weight) +double getWeight( +void setWeight(double weight) +static void setDailyPrice (double newPrice) +static void setNecessanWeight(double newNecessaryWeight) +boolean canMarket + double price( +void print() getWeight() and setWeight() methods correspond to getter and setter for the weight attribute. .setDailyPrice(): set the new daily price for all chickens. setNecessary Weight(): set the necessary weight to market a chicken. canMarket(): return true if the weight of a chicken is greater or equal to the necessary weight and false otherwise. price(): return the price of chicken (weight * dailyPrice) if the chicken have the necessary weight and 0 otherwise. .print(): print the id and the weight of the chicken. If the chicken is ready for market print "ready for market" and give the price. Otherwise print "dont have the necessary weight". Define a driver class that contains a main method and test the functionality of the above class.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Based on the class diagram provided in the image here is an implementation of the Chicken class in J... 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

Discovering Advanced Algebra An Investigative Approach

Authors: Jerald Murdock, Ellen Kamischke, Eric Kamischke

1st edition

1559539844, 978-1604400069, 1604400064, 978-1559539845

More Books

Students also viewed these Programming questions

Question

Find the perimeter of this triangle. t8(2.5 B(Q.5 A(-4,2 -*icd-s)t

Answered: 1 week ago

Question

2. In which brain areas do new neurons form in adultspg109

Answered: 1 week ago

Question

1. Which develops first, a neurons axon or its dendritespg109

Answered: 1 week ago