Introduction to Java Programming and Data Structures, Comprehensive Version Plus MyProgrammingLab with Pearson EText -- Access Card Package
bartleby

Concept explainers

Question
Book Icon
Chapter 22, Problem 22.27PE
Program Plan Intro

Program for optimal bin packing

Program plan:

  • Import the required package.
  • Create the class “Ex_27”.
  • In the main() function,
    • Create the object to read the number of objects.
    • Read the weight of objects.
    • Execute the for loop until the length of list.
    • Call the method generatePermutation() to generate the permutations possible for the list.
    • Call the method findBest() to find the best container.
    • Execute the for loop to print the containers with respective weight of objects.
  • Define the method findBest(),
    • Return the best bin of the list.
  • Define the method generatePermutation(),
    • Generate the number of permutation possible from the array list.
  • Define the static method firstfit(),
    • Return the item which fits first in the container.
  • Create the class “Bin”,
    • Assign the values of maximum and total weight of bins.
    • Define the method addItem(),
      • Add the weight of item.
    • Define the method getNumberOfObjects(),
      • Return the number of objects.
    • Define the method getTotalWeight(),
      • Return the totalweight.
    • Define the method getMaxWeight(),
      • Return the maximum weight.
    • Define the method toString(),
      • Return the string representation of output.

Blurred answer
Students have asked these similar questions
Need help in python. Problem: 2D random walk. A two dimensional random walk simulates the behavior of a particle moving in a grid of points. At each step, the random walker moves north, south, east, or west with probability 1/4, independently of previous moves. Compose a program that takes a command-line argument n and estimates how long it will take a random walker to hit the boundary of a 2n+1-by-2n+1 square centered at the starting point. //Given codeImport stdioImport randomImport sysn = int(sys.argv[1])//write code herestdio.write('The walker took    ')stdio.write(c)stdio.writeln('    steps')
2) A BMI Calculator: the body mass index (BMI) is a measure used to determine whether a person is overweight or not. We can calculate BMI from the weight of the person (in pounds) and the height (in inches) of the person. The formula for calculating BMI is: BMI = (weightInPounds 703) divided by (heightInInches squared) In this problem, you will have to create a BMI calculator, i.e., a Java program, that reads the user's weight in pounds and height in inches, then calculates and displays the user's body mass index BMI. Also, display the following information from the US Department of Health) so the user can evaluate his/her BMI: BMI values: Underweight: less than 18.5 Normal: between 18.5 and 24.9 Overweight: between 25 and 29.9 Obese: 30 or greater
*Using Python   The scientist has 500 cages in which to hold her rabbits. Each cage holds one pair of rabbits. Assuming that no rabbits ever die, when will she run out of cages? Your program must do the following: Print a table that contains the following information for each month. The number of months that have passed. The number adult rabbit pairs (those over 1 month old). The number of baby rabbits pairs produced this month. The total number of rabbit pairs in the lab. Calculate how many months it will take until the number of rabbits exceeds the number of available cages. Stop printing when you run out of cages. Print a message giving how many months it will take to run out of cages Output file should look like the following.  Comments in the file begin with '#', and must appear as shown too:   Code must contain def main(): #main function need in all programs for automated testing """ Program starts here """ #end of main program if __name__ == '__main__': main() #excucte main…

Chapter 22 Solutions

Introduction to Java Programming and Data Structures, Comprehensive Version Plus MyProgrammingLab with Pearson EText -- Access Card Package

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr