Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA Array and Loop Question. There are two arrays, one holds time and one holds amount, each corresponding to each other. arrA= [ 0, 2,

JAVA Array and Loop Question.

There are two arrays, one holds time and one holds amount, each corresponding to each other.

arrA= [ 0, 2, 3, 0, 2]

arrB = [500, 100, 400, 650, 50]

From these I must find the maximum sum of array B with correspondence of arrA being the urgency #.

So for example from the arrays above: from arrA there are two 0s. I must pick the one with the highest amount, in this case 650. Then the next is there are two 2s, and pick the max amount which is 100, and 3 is just one. From this my max sum should be 1150. What would be the loop behind this algorithm, tried to do it but got very confused.

EXTRA: with each loop iteration, arrA elements must decrease by 1. so for i =1, arrA = [ 0, 1, 2, 1, 0], if i=2 arrA = [0, 0, 1, 0, 0], etc...

It would be nice if you could help me with this but just showing the above one is fine too. Thank you, will give thumbs up for correct code.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Hands-On Database

Authors: Steve Conger

2nd Edition

0133024415, 978-0133024418

More Books

Students also viewed these Databases questions

Question

What is dividend payout ratio ?

Answered: 1 week ago

Question

Explain the factors affecting dividend policy in detail.

Answered: 1 week ago