Question: Please use Java to solve this problem Problem Cases Output 05m 465 The current selected programming language is Java. We emphasize the submission of a
Please use Java to solve this problem


Problem Cases Output 05m 465 The current selected programming language is Java. We emphasize the submission of a fully working code over partially correct but efficient code. Once submitted, you cannot review this problem again. You can use System.out.printin to debug your code. The System.out.printin) may not work in case of syntax/runtime error. The version of JDK being used is 1.8 Amazon Fresh trucks can hold two containers on each shelf, provided the sum of their weights does not exceed the given maximum capacity of the shelf. To most efficiently pack the trucks for delivery, each shelf should be loaded with the heaviest two containers that the shelf can support. Write an algorithm to find the weights of two containers chosen to be carried on the shelf. Input The input to the function/method consists of three arguments numContainers, an integer representing the number of containers, maxCapacity, a real number representing the maximum capacity of the shelf containersWt, a list of real numbers representing the weight of the containers. Output Return a pair of real numbers representing the weights of the two heaviest containers chosen to be carried on the shelf. Constraints 0 containersWti O si numcontainers Note There is at least one pair whose combined weight is less than or equals to the maximum capacity of the shelf If more than one such pair is possible, then output any one of them. The order of numbers in the output does not matter Example Input numContainers 6 maxCapacity 433 Problem Test Cases Output Java 05m 265 Note There is at least one pair whose combined weight is less than or equals to the maximum capacity of the shelf. If more than one such pair is possible, then output any one of them. The order of numbers in the output does not matter Example Input: numcontainers 6 maxCapacity 433 containersWt 7.33, 8.13, 103.7313, 11.24, 23.79, 18.3501] 0 Output: [23.79, 18.3501] Explanation: The weight of the two heaviest containers with sum 43.3 is 23.79 and 18.3501. So, the output can be [23.79, 18.3501] or [18.3501, 23.79] Helper Descriptionn The following structure is used to represent a Pair and is already implemented in the default code (Do not write this definition again in your code): class Pair double first; double second; Pair double first, double second) this.firstfirst; this.secondsecond
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
