Need help with your Discussion

Get a timely done, PLAGIARISM-FREE paper
from our highly-qualified writers!

glass
pen
clip
papers
heaphones

SMC Java Software Engineer Project

SMC Java Software Engineer Project

SMC Java Software Engineer Project

Description

Problem 1:

( 10 points ) Given the uncertainty surrounding the outbreak of the Coronavirus disease (COVID-19) pandemic in 2020, the federal government has to work tirelessly to ensure the distribution of needed resources such as medical essentials, water, food supply among the states, townships, and counties in the time of crisis.

You are a software engineer from the Right Resource, a company that delivers logistic solutions to local and state entities (schools, institutions, government offices, etc). You are working on a software solution to check that given a set of resources, whether they can be proportioned and distributed equally to k medical facilities. Resources are represented as an array of positive integers. You want to see if these resources can be sub-divided into k facilities, each having the same total sum (of resources) as the other facilities. For example with resources = {1,2,3,4,5,6} we can sub-divide them into k = 3 medical facilities, each having the same total sum of 7: {1,6}, {2,5}, and {3,4}.

EXAMPLES

input: {3,4,5,6}, 2

output: true

Explanation: {3,6}, {4,5}

input: {1}, 1

output: true

Explanation: {1}

input: {1 , 3 , 2 , 3 , 4 , 1 , 3 , 5 , 2 , 1}, 5

output: true

input: {1}, 4

output: false

Explanation: cannot split further with a value of 1 in resource.

HINTS

  • Note: you may choose to solve this problem in your own way or use the following pseudo code.
  • Check for all boundary conditions to return result immediately if known, e.g., resources.length() = 1 and k = 1, return true, resources.length() = 1 and k = 4, return false, etc.
  • Find the purported allocation for each group, i.e., allocation = SUM(resources)/k.
  • Sort the resources in either ascending or descending order.
  • Create another solution method of your choice to enable recursion.
  • Remaining Pseudo Code:
    1. Create an empty array of integers with k elements. This is your “memory buffer”. At the end of your recursion, you want this memory buffer be filled with equally allocated values, allocation.
    2. Pick the highest resource (one with the highest integral value) in your resources.
    3. Check if the selected resource is <= allocation:
      • If yes, add that value to the first available element in your memory buffer of k elements. Go to #4.
      • If not, move on to other elements in your memory buffer to see if there’s available space to accommodate it.
      • If there’s no available space to accommodate the selected resource, it is impossible for resources to be allocated equally.
    4. Advance to the next highest resource. Repeat Step #3. If all resources have been considered and there is no more next highest, go to Step #5.
    5. Check if every element in your memory buffer has the same value. If so you have an evenly allocated distribution – return true. False otherwise.

SUBMISSION

  • Submit your solution in HW4_1.java.
  • There are two classes in this Java code. One of them is your HW4_1 class, and the other is the same top-level class (the one without the public access modifier) named Solution.

STARTER CODE

Write a solution method, canDistribute, that returns whether it is possible (true or false) that a given set of resources divides into k equal-sum facilities. You will solve this problem using a recursion:

public class HW4_1 {    
   public static void main(String[] args) {
      // your solution will be tested as such, sequentially with random input
      Solution sol = new Solution();
      sol.canDistribute(new int[]{1}, 2);
      sol.canDistribute(new int[]{1,2,2,3,3,5,5}, 12);
      // etc.
   }
}

/**
 * PURPOSE:
 * PARAMETERS:
 * RETURN VALUES:
*/
class Solution {
   public boolean canDistribute(int[] resources, int groups) { 
      // YOUR CODE HERE 
   } 

}

Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."

Order Solution Now

Our Service Charter


1. Professional & Expert Writers: Eminence Papers only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed of papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by Eminence Papers are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. Eminence Papers are known for the timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit in all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At Eminence Papers, we have put in place a team of experts who answer all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.

We Can Write It for You! Enjoy 20% OFF on This Order. Use Code SAVE20

Stuck with your Assignment?

Enjoy 20% OFF Today
Use code SAVE20