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...

  • please help part one) Calories Burned Running on a particular-treadmill you burn 3.9 calories per minute....

    please help part one) Calories Burned Running on a particular-treadmill you burn 3.9 calories per minute. Design a pro- gram that uses a loop to display the number of calories burned after 10, 15, 20, 25, and 30 minutes. 3 part two) Sum of Numbers Design a program with a loop that asks the user to enter a series of positive num bers. The user should enter a negative number to signal the end of the series. After all the...

  • 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 need help with this problem please, This code needs to be in Ruby, Java, or...

    I need help with this problem please, This code needs to be in Ruby, Java, or Python. See problem below. -5 - Functional Programming (due Mon] Assignment Content Your software company was invited to provide a proposal for a company in Australia. You currently have the cost in US dollars and need to convert the prices to the Australian dollar. Write a 2-part program using Ruby, Java, or Python. Part 1: Write a function to gather the following costs from...

  • I only need help with the top part. I can not see the other parts to...

    I only need help with the top part. I can not see the other parts to the question Animal Transport Company makes two pet carriers, the Cat-allac and the Dog-eriffic. They are both made of plastic with metal doors, but the Cat-allac is smaller. Information for the two products for the month of April is given in the following tables: E: (Click the icon to view the information for the two products.) Animal Transport accounts for direct materials using a...

  • 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...

  • need help with this assignment, please. Part 1 - Java program named MemoryCalculator In your Ubuntu...

    need help with this assignment, please. Part 1 - Java program named MemoryCalculator In your Ubuntu VM (virtual machine), using terminal mode ONLY, do the following: Create the folder program2 In this folder place the text file located on my faculty website in Module 2 called RAMerrors (Do not rename this file, it has no extension.) It is down below. Ths is the file RAMErrors 3CDAEFFAD ABCDEFABC 7A0EDF301 1A00D0000 Each record in this file represents the location of an error...

  • Hi there I need help coming up with the C code for this problem. At the...

    Hi there I need help coming up with the C code for this problem. At the beginning of the program and before each function use comments to explain what the function does. Do not use global variables 1. The Pascal triangle can be used to compute the coefficients of the terms in the expansion of atb In a Pascal triangle, each element is the sum of the element directly above it and the element to the left of the element...

  • I need help with e and f please. $100 for a house taking four hours of...

    I need help with e and f please. $100 for a house taking four hours of cleaning, her standard product offering. she cleans, she uses $5 in variable supplies such as cleaning fluids and pape has fixed costs of an accountant, a van, a vacuum cleaner, and sundry items a $25,000 per year. 5. CVP ANALYSIS. Angie's Cleaning Service does routine cleaning or nouses REQUIRED: a. Develop Angie's cost formula for cleaning houses b. What is Angie's breakeven point in...

  • Help Please on JAVA Project: Validating the input is where I need help. Thank you Requirements...

    Help Please on JAVA Project: Validating the input is where I need help. Thank you Requirements description: Assume you work part-time at a sandwich store. As the only employee who knows java programming, you help to write a sandwich ordering application for the store. The following is a brief requirement description with some sample output. 1. Selecting bread When the program starts, it first shows a list/menu of sandwich breads and their prices, then asks a user to select a...

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
ADVERTISEMENT