Question

I need help with Part 2! Coded in Java please! Abby wants to start a backyard...

I need help with Part 2! Coded in Java please!

Abby wants to start a backyard chicken egg business. As any good she wants to “count the costs” of such an operation to determine if she can make a profit. While there are a number of variables, naturally the most influential ones are:

  • Number of chickens
  • Average number of eggs laid per day per chicken
  • Pounds of feed per chicken per day
  • Cost per pound for feed
  • Empty carton cost

Not being much of a programmer yet, she needs your help by writing a program which will help her assess the viability of her venture. The program should fulfill the following requirements:

Part 1:

  1. Prompt the user for the variables noted above.
  2. If the user enters 0 for number of chickens, end the program (Hint: break out of the while loop).
  3. When all the parameters are entered, echo them back to the user identifying each one.
  4. Calculate the total cost of the operation per month. (Assume 30 days)
  5. Determine the cost to produce each dozen eggs. (Note: you may ignore any left-over eggs)

Part 2:

  1. Since the number of chickens, eggs laid per chicken, and pounds of feed per chicken per day, scale linearly with the operation it becomes apparent that the profit or loss of the venture is heavily influenced by the cost of the feed. A larger flock could command bulk feed purchases resulting in a lower per pound costs. However, the time of year and weather may also impact the cost of feed. As such, Abby wants to calculate the cost per dozen with the supplied feed cost varied from -25% to +25% at 5% intervals. At each interval, output the cost per dozen assuming the other variables remain constant.

Hint: The easiest way to do this is to let the percent be controlled in a for-loop varying from -25 to 25 with a step of 5.

Part 3:

            Using UMLet or Draw.IO draw an activity diagram to document your programs implementation.


part one will be needed to be solved inorder to do part 2
0 0
Add a comment Improve this question Transcribed image text
Answer #1
import java.util.Scanner;
public class profit_part1 {
    int profit(int num_of_chickens,int eggs_perchicken_perday,int feed_perchicken_perday,int cost_perfeed_pound,int empty_cartoon_cost,int cost_of_one_egg)
    {    if(num_of_chickens==0)
          return 0;

        int profit_per_day=0;
        profit_per_day=(eggs_perchicken_perday*num_of_chickens*cost_of_one_egg)-(feed_perchicken_perday*cost_perfeed_pound*num_of_chickens)-empty_cartoon_cost;
        int profit_per_month=profit_per_day*30;

        int per_dozen=0;
        per_dozen=(profit_per_month/(num_of_chickens*eggs_perchicken_perday*30))*12;

        System.out.println("The cost per month is: "+profit_per_month);
        System.out.println("The cost of per dozen egg is: "+per_dozen);
        return 1;
    }
}
public class profit_part2 {

    int profit(int num_of_chickens,int eggs_perchicken_perday,int feed_perchicken_perday,int cost_perfeed_pound,int empty_cartoon_cost,int cost_of_one_egg)
    {    if(num_of_chickens==0)
        return 0;

        double profit_per_day=0;
        double new_feed_cost=0;
        //for the feed cost varying from -25% to 0%
        for(double i=25;i>=0;i=i-5)
        {
           new_feed_cost=cost_perfeed_pound-((i/100)*cost_perfeed_pound);
            profit_per_day=(eggs_perchicken_perday*num_of_chickens*cost_of_one_egg)-(feed_perchicken_perday*new_feed_cost*num_of_chickens)-empty_cartoon_cost;
            double profit_per_month=profit_per_day*30;

            double per_dozen=0;
            per_dozen=(profit_per_month/(num_of_chickens*eggs_perchicken_perday*30))*12;

            System.out.println("the cost per dozen is: "+per_dozen);
        }
        //for the feed cost varying from 5% to 25%
        for(double i=5;i<=25;i=i+5)
        {
            new_feed_cost=cost_perfeed_pound+((i/100)*cost_perfeed_pound);
            profit_per_day=(eggs_perchicken_perday*num_of_chickens*cost_of_one_egg)-(feed_perchicken_perday*new_feed_cost*num_of_chickens)-empty_cartoon_cost;
            double profit_per_month=profit_per_day*30;

            double per_dozen=0;
            per_dozen=(profit_per_month/(num_of_chickens*eggs_perchicken_perday*30))*12;

            System.out.println("the cost per dozen is: "+per_dozen);
        }
        return 1;
    }
}
public class main {
 public  static  void main(String args[]) {
     Scanner sc = new Scanner(System.in);
     int num_of_chickens, eggs_perchicken_perday, feed_perchicken_perday, cost_perfeed_pound, empty_cartoon_cost, cost_of_one_egg;
     num_of_chickens = sc.nextInt();
     eggs_perchicken_perday =sc.nextInt();
     feed_perchicken_perday=sc.nextInt();
     cost_perfeed_pound=sc.nextInt();
     empty_cartoon_cost=sc.nextInt();
     cost_of_one_egg=sc.nextInt();

     profit_part1 p1=new profit_part1();
     p1.profit(num_of_chickens, eggs_perchicken_perday, feed_perchicken_perday, cost_perfeed_pound, empty_cartoon_cost, cost_of_one_egg);
     profit_part2 p2=new profit_part2();
     p2.profit(num_of_chickens, eggs_perchicken_perday, feed_perchicken_perday, cost_perfeed_pound, empty_cartoon_cost, cost_of_one_egg);

 }
}
Add a comment
Know the answer?
Add Answer to:
I need help with Part 2! Coded in Java please! Abby wants to start a backyard...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Code in Java please, I am very confused... Abby wants to start a backyard chicken egg...

    Code in Java please, I am very confused... Abby wants to start a backyard chicken egg business. As any good she wants to “count the costs” of such an operation to determine if she can make a profit. While there are a number of variables, naturally the most influential ones are: Number of chickens Average number of eggs laid per day per chicken Pounds of feed per chicken per day Cost per pound for feed Empty carton cost Not being...

  • Hey guys, I need help writing a Tic-Tac-Toe game programmed in Java. The game has to...

    Hey guys, I need help writing a Tic-Tac-Toe game programmed in Java. The game has to be a 1D (One-Dimension) array board NOT 2D. It has to be a human plays against the computer type of Tic-Tac-Toe. Here is the requirements for the program. PLEASE NO COPY AND PASTE ANSWER. Thank you in advance! You will develop a program in which a human plays against the computer. 1. Validate user input at every opportunity. a. Do not allow number entries...

  • I mainly need help with the second part. Thank you in advance! Starbucks launched its prepaid...

    I mainly need help with the second part. Thank you in advance! Starbucks launched its prepaid (debit) Starbucks Card in November 2001. The card, which holds between $5 and $500 can be used at any Starbucks location. Suppose Starbucks management wants to study the reasons why some people purchase debit cards with higher prepaid amounts than do other people. Suppose a study of 25 randomly selected prepaid purchasers is taken. Respondents are asked the amount of the prepaid card, the...

  • Can you please help me with creating this Java Code using the following pseudocode? Make Change C...

    Can you please help me with creating this Java Code using the following pseudocode? Make Change Calculator (100 points + 5 ex.cr.)                                                                                                                                  2019 In this program (closely related to the change calculator done as the prior assignment) you will make “change for a dollar” using the most efficient set of coins possible. In Part A you will give the fewest quarters, dimes, nickels, and pennies possible (i.e., without regard to any ‘limits’ on coin counts), but in Part B you...

  • (I just need Question 2)Please show the steps clearly contract to produce 10 items of x...

    (I just need Question 2)Please show the steps clearly contract to produce 10 items of x per week for a particular customer. • Part (a). Formulate the problem of deciding how much to produce per week as a linear program. • Part (b). Draw the feasible region of your LP formulation. • Part (c). Find the optimal solution of your LP model using graphical solution method. 2. Consider a factory that produces tables. The demand for the tables is known...

  • For number 2, I need help with part C. BELOW THESE ARE WRONG ANSWERS FOR NUMBER...

    For number 2, I need help with part C. BELOW THESE ARE WRONG ANSWERS FOR NUMBER 2. 1.092 30.876 17.575 41.425 Demand for a book at Amazon.com is 220 units per week. The product is supplied to Amazon from a factory. The factory charges Amazon $8 per book, while the total cost of shipping an order from the factory to the Amazon, when the shipment size is Q, is given by Shipment cost = $60 + 20 Assume the annual...

  • i need help with d-1 d-2 and e please! Problem 7-15 Chec The Goodparts Company produces...

    i need help with d-1 d-2 and e please! Problem 7-15 Chec The Goodparts Company produces a component that is subsequently used in the aerospace industry. The component consists of three parts (A, B, and C) that are purchased from outside and cost 35, 30, and 10 cents per piece, respectively. Parts A and B are assembled first on assembly line 1, which produces 110 components per hour. Part C undergoes a drilling operation before being finally assembled with the...

  • Please help, need to code for this business assignment using c++. Business Expense Reimbursements Calculator Probl...

    Please help, need to code for this business assignment using c++. Business Expense Reimbursements Calculator Problem statement: Business trip is part of the enterprise culture. Suppose a businessperson just completed a business trip for your company. Now, you are tasked to write a program that calculates and displays the total travel expenses, allowable expenses for the trip, and the excess that must be paid by the businessperson, if any The program should prompt the user for the following . The...

  • I need help with this assignment. It's due Tuesday at 8 AM. Please follow the instructions thorou...

    I need help with this assignment. It's due Tuesday at 8 AM. Please follow the instructions thoroughly as to not use any advanced material we may not have gone over in class. The instructions let you know what all should be used. Thanks! Use only what you have learned in Chapters 1 - 7. Use of "advanced" material, material not in the text, or project does not follow the instructions, will result in a GRADE OF 0% for the project....

  • please help me with part 2 question Α. D ΕΕ ADC UTUP AS Tent Kolbec Community...

    please help me with part 2 question Α. D ΕΕ ADC UTUP AS Tent Kolbec Community College (KCC) has 4,000 full-time students and offers a variety of academic programs in three areas: professional studies, arts, and technology. The professional studies programs prepare students for administrative and clerical jobs in a variety of professional settings, including accounting, medicine, and law. The arts program's offerings are wide ranging and include graphic design, digital animation, culinary arts, cosmetology, and music arts. The technology...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT