Calculate the profit share of B - Java Quiz Question


Write a program to calculate the profit share of B given the investments and the number of Months of the partners A, B and C. The total profit is also given.

Input (Investment, Investment, Investment, double) Output (double)
A = ["A", 500, 12], B = ["B", 800, 8], C = ["C", 600, 6] profit = 260.0 104.0
A = ["A", 10000, 12], B = ["B", 8000, 8], C = ["C", 4000, 10] profit = 2800.0 800.0
A = ["A", 50, 2], B = ["B", 90, 5], C = ["C", 10, 5] profit = 30.0 22.5
A = ["A", 5000, 20], B = ["B", 2000, 20], C = ["C", 9000, 15] profit = 3300.0 480.0


import java.util.*;
class CalculateProfitShareOfB
{
    public static void main(String s[])
    {
        Investment A = new Investment("A", 20000, 24);
        Investment B = new Investment("B", 15000, 24);
        Investment C = new Investment("C", 20000, 18);
        double profit = 25000.0;
        System.out.println("The B's profit is : " + calculateProfit(A, B, C, profit));

    }


    public static double calculateProfit(Investment a, Investment b, Investment c, double profit) {
    }

}
class Investment {

String name;
int amount;
int numberOfMonths;

public Investment(String name, int amount, int numberOfMonths) {
this.name = name;
this.amount = amount;
this.numberOfMonths = numberOfMonths;
}
}