Q. Write a Java Progr A chickens farmer receives from a supplier young chicken that he...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Answer rating: 100% (QA)
Based on the class diagram provided in the image here is an implementation of the Chicken class in J... View the full answer
Related Book For
Discovering Advanced Algebra An Investigative Approach
ISBN: 978-1559539845
1st edition
Authors: Jerald Murdock, Ellen Kamischke, Eric Kamischke
Posted Date:
Students also viewed these programming questions
-
The Crazy Eddie fraud may appear smaller and gentler than the massive billion-dollar frauds exposed in recent times, such as Bernie Madoffs Ponzi scheme, frauds in the subprime mortgage market, the...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
The California State Auditors Office assesses the fiscal health of the states cities and posts the information on Fiscal Health of California Cities (www.auditor.ca.gov/ bsa/cities_risk_index). The...
-
Answer the following: (A) Find the binomial probability P(x = 5), where n = 12 and p = 0.30. (B) Set up, without solving, the binomial probability P(x is at most 5) using probability notation. (C)...
-
Jiminys Cricket Farm issued a 30-year, 6 percent semiannual bond three years ago. The bond currently sells for 93 percent of its face value. The companys tax rate is 22 percent. a. What is the pretax...
-
John Carr, controller for the General Corporation, provides you with the following information relative to the company's sales system: The sales department prepares a six-part sales invoice form from...
-
Cam and Anna are very satisfied with their first month of operations. Their major effort centered on signing various artists to live performance contracts, and they had more success than they had...
-
Your fire department (or agency) is developing a working group to address concerns, develop strategies, and implement comprehensive solutions to improve the health and safety of all members. The...
-
Refer to Exercise 13-4. Using the same information, assume that the Brazilian real is identified as the functional currency of the subsidiary. Required: A. Remeasure the account balances that are...
-
The new spaceport has a single runway for launching space planes. Space airlines (Virgin Atlantic, for example) plan to launch 5 flights per hour. The average time to launch each ship is 9.2 minutes....
-
In Python generate 4096 "flips" of the coin using the binomial function of the random module in numpy: import numpy.random flips = numpy.random.binomial(1, bias, 4096) Where bias is the value of the...
-
If an edge detector is as follows: Convolve image f(x)with go Convolve f(x)with go to form h(x). h(x)-h(x) Compute h(x) = 0-01 Find zero-crossings of h3 (x). e 1|X to form h (x). a. Describe how...
-
Explain the Westgard R4s rule and what type of error it detects. The following results for the new Level 1 Control were obtained. Define and calculate the mean, median, mode, SD, and CV of the data....
-
3. (6 pts) Evaluate the following expressions based off of the graph of f below. If a value does not exist, explain why. 2 = f(x) 1 AN -2 -1 1 -2 4 a) lim f(x) x-1- c) f(1) e) lim f(x) x1 b) lim f(x)...
-
Consider the dynamics for the underlying asset: dS(t) = S(t)dt + v(t)S(t)dZ (t), dv(t) -Bv(t)dt + ddz(t), = where S(t) is the stock price, v(t) is the volatility, Z(t) and Z(t) are Wiener processes...
-
Eight of the 22 books on a shelf are Probability Theory textbooks. Nehemiah randomly draws six textbooks from the shelf. What is the probability that among the six textbooks that Nehemiah is going to...
-
In July 2013, cnet.com listed the battery life (in hours) and luminous intensity (i. e., screen brightness, in cd/m2) for a sample of tablet computers. We want to know if screen brightness is...
-
Find the perimeter of this triangle. t8(2.5 B(Q.5 A(-4,2 -*icd-s)t
-
Prove each identity. The sum and difference identities will be helpful. a. cos (2 - A) = cos A b. sin(3/2 -A) = -cos A
-
Which of these numbers comes from a geometric random variable? Explain. a. The number of phone calls a telemarketer makes until she makes a sale b. The number of cats in the home of a cat owner c....
-
Which forecasting technique is more qualitative, the Delphi method or linear regression?
-
A road-paving crew required 8 hours to repave a 3-mile stretch of road, using \($5,000\) in materials. The crew consisted of three workers who each earn \($25\) an hour. Calculate a multifactor...
-
An automobile assembly plant produced 600 cars during a 5-day workweek. It then produced 500 cars the following week, although it only operated 4 days due to a national holiday. During which week was...
Study smarter with the SolutionInn App