Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java8 please 3. Maximum Order Volume During the day, a supermarket will receive calls from customers who want to place orders. The supermarket manager

In Java8 please

imageimageimageimageimage

3. Maximum Order Volume During the day, a supermarket will receive calls from customers who want to place orders. The supermarket manager knows in advance the number of calls that will be attempted, the start time, duration and order volume for each call. Only one call can be in progress at any one time, and if a call is not answered, the caller will not call back. The manager must choose which calls to service in order to maximize order volume. Determine that maximum order volume. Example start = [10, 5, 15, 18, 30] duration = [30, 12, 20, 35, 35] volume = [50, 51, 20, 25, 10] Solve question 2 The above data as a table: Caller 1 2 3 4 5 Start time 10 5 15 18 30 Duration 30 12 20 35 35 The first call will start at time = 10, and last until time = 40. The second call will start at time = 5, and last until time = 17. The third call will start at time = 15, and last until time = 35. The fourth call will start at time = 18, and last until time = 53. The fifth call will start at time = 30, and last until time = 65. Order volume 50 51 20 25 10 The first call completely overlaps the second and third calls, and partially overlaps the fourth and fifth calls. Choosing calls that do not overlap, answering the 2nd and 4th calls will lead to the maximum total order volume of 51 + 25 = 76. Function Description Function Description Complete the function phoneCalls in the editor below. phoneCalls has the following parameter(s): int start[n]: the start times of each call int duration[n]: the durations of each call int volume[n]: the volumes of each order Returns int: the maximum possible volume of orders that can be received Constraints 1n105 startli) 109 Solve question 2 1- duration[i] 10 1 volume[i] 10 Input Format For Custom Testing The first line contains an integer, n, the size of the start array. Each line i of the n subsequent lines (where 0 Sample Case 0 Sample Input For Custom Testing STDIN Function 3 1 N N WANT 2 4 3 2 WNT Modify submission of question 1, h = 3 1 volume[] = [1, 2, 3 ] 2 start[] size n = 3 start[] = [1, 2, 4 ] 3 duration [] size n = 3 duration[] = [ 2, 2, 1 ] Sample Output Explanation The calls happen in the intervals [1,3] [2,4] [4,5] The first and third calls together make up the order volume 4, and their intervals do not intersect. The first and second calls intersect, as do the second and third calls. Only one call from either of these pairs can be serviced. The most efficient calls to answer are the first and third with a total volume of 4. > Sample Case 1 Sample Input For Custom Testing STDIN Function 3 1 10 100 3 1 10 100 - 3 1 10 100 ----- start [] size n = 3 start[] = [1, 10, 100 ] duration [] size n = 3 duration[] = [1, 10, 100 ] volume [] size n = 3 volume[] = [ 1, 10, 100 ] Sample Output 111 Explanation The calls happen in the following intervals - [1 2] [10 20] [100 200] All three calls can be attended. So total volume is 1 + 10 + 100 = 111. Language Java 8 1 > import java.io.*; 14 15 class Result { 16 17 99872~*~M & H M M G 18 19 20 21 22 23 24 25 26 30 31 32 33 34 35 37 38 39 40 41 42 43 ? 4 45 46 7 48 49 50 1 52 53 44 47 } 36 public class Solution { 51 } * Complete the phone Calls function below. * The function is expected to return an INTEGER. * The function accepts following parameters: * 1. INTEGER_ARRAY start * */ V Autocomplete Ready 2. INTEGER_ARRAY duration 3. INTEGER_ARRAY volume public static int phoneCalls (List start, List duration, List volume) { // Write your code here public static void main(String[] args) throws IOException { BufferedReader buffered Reader = new Buffered Reader (new InputStreamReader (System.in)); BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter (System.getenv ( OUTPUT_PATH ))); int startCount = Integer.parseInt(bufferedReader.readLine().trim()); List start = IntStream.range (0, startCount).mapToobj (i -> { try { }) return buffered Reader.readLine().replaceAll( \\s+$ , ); } catch (IOException ex) { } throw new RuntimeException (ex); .map (String::trim) .map (Integer::parseInt) .collect(toList()); -0- ? Line: 30 Col: 9

Step by Step Solution

3.39 Rating (155 Votes )

There are 3 Steps involved in it

Step: 1

import javautil public class Solution public static int phoneCallsList start List duration List volu... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Management Science A Modeling And Cases Studies Approach With Spreadsheets

Authors: Frederick S. Hillier, Mark S. Hillier

5th Edition

978-0077825560, 78024064, 9780077498948, 007782556X, 77498941, 978-0078024061

More Books

Students also viewed these Electrical Engineering questions