Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
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
Implement programs involving the use of while, do..while and for loop statement. Objectives: Topics Covered: Implementing programs using loops. Description FRIDAY THE 13TH When will Friday the 13th occur in 1990? Write a program that will find all months in 1990 in which the 13th falls on a Friday. You need to know the following. 1. January 1, 1990 was on a Monday. 2. September, April, June, and November have thirty days, all the rest have 31 except for February which has 28 except in leap years when it has 29. 3. 1990 is not a leap year. Note: To make it fair for everyone, you may not use any built-in date functions from your computer language. Sample Output if Applicable Sample Run In 1990, Friday the 13th occurs in the months: APRIL

Chapter 22 Solutions

Introduction to Java Programming and Data Structures, Comprehensive Version (11th 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