Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)
Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)
11th Edition
ISBN: 9780134671710
Author: Y. Daniel Liang
Publisher: PEARSON
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
[Python Language] Using loops of any kind, lists, or Sets is not allowed. Sloan’s Book Collection Sloan loves reading books. She recently started reading an AI generated series called “Harry Trotter”. Sloan is collecting books from the series at her nearest bookstore. Since the series is AI generated, the publishers have produced an infinite collection of the books where each book is identified by a unique integer. The bookstore has exactly one copy of each book. Sloan wants to buy the books in the range [l,r], where l ≤ r. As an example, the range [−3,3] means that Sloan wants to buy the books  − 3,  − 2,  − 1, 0, 1, 2, and 3. Pam also loves the series (or maybe annoying Sloan– who knows, really), and he manages to sneak into the bookstore very early to buy all of the books in the range [d,u], where d ≤ u. When Sloan later visits, sadly she will not find those books there anymore. For example, if Sloan tries to buy books [−2,3] and Pam has bought books [0,2], Sloan would only receive…

Chapter 22 Solutions

Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)

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