Use java programming for the following questions to have the solutions ready within today Jan 3 2020 at or before 7:00PM GMT+8 time zone:
Question 13
Some service fees (% of asset amount) of two investment companies are shown in the following tables:
|
Company A: |
|
|
Service Fee Type |
Fee |
|
Management Fee |
1.5 |
|
Subscription Fee |
5.0 |
|
Redemption Fee |
1.0 |
|
Company B: |
|
|
Service Fee Type |
Fee |
|
Platform Fee |
0.2 |
|
Management Fee |
1.0 |
|
Subscription Fee |
2.0 |
The above information is to be stored in two maps (Map<String, Double>) referenced by companyA and companyB for Company A and Company B respectively. The service fee type is assumed to be unique in each map and it is the key of it.
// TEXT CODE
import java.util.HashMap;
import java.util.Map;
public class CompanyService {
public static void main(String[] args){
// Solving part A)
// creating companyA map reference
Map<String, Double> companyA = new HashMap<>();
// creating companyB map reference
Map<String, Double> companyB = new HashMap<>();
// adding companyA service information
companyA.put("Management Fee", 1.5);
companyA.put("Subscription Fee", 5.0);
companyA.put("Redemption Fee", 1.0);
// adding companyB service information
companyB.put("Platform Fee", 0.2);
companyB.put("Management Fee", 1.0);
companyB.put("Subscription Fee", 2.0);
// solving part B)
// creating an array to store the number of service fee types in each three fee categories
int[] serviceTypesCount = new int[3];
// using enhanced for loop to get the number of service fee types
for(Map.Entry<String, Double> entry: companyA.entrySet()){
// if category is "fee <= 0.5" store count at index 0
if(entry.getValue() <= 0.5)
serviceTypesCount[0]++;
// if category is "0.5 < fee <= 1.0" store count at index 1
if(0.5 < entry.getValue() && entry.getValue() <= 1.0 )
serviceTypesCount[1]++;
// if category is "fee > 1.0" store count at index 2
if(entry.getValue() > 1.0)
serviceTypesCount[2]++;
}
// printing number of service fee types of each category
System.out.println(".......Number of service fee types in each fee category for companyA........");
System.out.println("Category \"fee <= 0.5\" count is: " + serviceTypesCount[0]);
System.out.println("Category \"0.5 < fee <= 1.0\" count is: " + serviceTypesCount[1]);
System.out.println("Category \"fee > 1.0\" count is: " + serviceTypesCount[2]);
// Solving part C)
System.out.println("\nPrinting the name of each service fee available in both of the companies (A and B) and its lowest fee.");
for (Map.Entry<String, Double> companyAEntry: companyA.entrySet()){
String key1 = companyAEntry.getKey();
// check if key1 is present in companyB or not
if(companyB.containsKey(key1)){
// get the lowest fee
double minFee = 0.0;
if(companyA.get(key1) < companyB.get(key1)){
minFee = companyA.get(key1);
}else minFee = companyB.get(key1);
// print out the name of each service fee available in both of the companies (A and B) and its lowest fee
System.out.println(key1 + " " + minFee);
}
}
}
}
// SCREENSHOT OF CODE
![import java.util.HashMap; import java.util.Map; public class Company Service { public static void main(String[] args) { // so](http://img.homeworklib.com/questions/a21084a0-9c23-11ea-8eef-f13c97452e3d.png?x-oss-process=image/resize,w_560)
![serviceTypesCount[2]++; // printing number of service fee types of each category System.out.println(.......Number of service](http://img.homeworklib.com/questions/a27b0750-9c23-11ea-9807-59ed9786282d.png?x-oss-process=image/resize,w_560)
// OUTPUT

Use java programming for the following questions to have the solutions ready within today Jan 3...
Some service fees (% of asset amount) of two investment companies are shown in the following tables: Company A: Service Fee Type Fee Management Fee 1.5 Subscription Fee 5.0 Redemption Fee 1.0 Company B: Service Fee Type Fee Platform Fee 0.2 Management Fee 1.0 Subscription Fee 2.0 The above information is to be stored in two maps (Map<String, Double>) referenced by companyA and companyB for Company A and Company B respectively. The service fee type is assumed to be unique...
Use java programming for the following questions to have the solutions ready within today Jan 3 2020 at or before 8:00PM GMT+8 time zone: Question 10 Declare a local String variable id and initialize it with your 8-digit student ID in string form. What is the output of the following program segment? String str = id + " "; // two spaces System.out.println(str.indexOf("5") + " + " + str.substring(0,2) + "\n" + str.trim().substring(5)+ "#"); The class List below is in...
Use java programming for the following questions to have the solutions ready within today Jan 3 2020 at or before 8:00PM GMT+8 time zone: Question 5 A method secret() of a class F is shown below: public int secret(String[] stringArray, int n) { int num = 0; for (int i=0; i<stringArray.length; i++) if (stringArray[i].indexOf("a", n) >= 0) num++; return num; } A program segment using the method is: F f = new F(); String[] array01 = {"an", "easy", "exam", "on",...