Menu
Question Index
...


Write a program to get the love index of couple. The index is calculated by cancelling out the common letters in the names, then summing up the remaining letters for each name and then dividing the small character sum with the bigger character sum. And finally multiplying the result with hundred. Note that both small and capital letters will have the same weightage, so 'M' and 'm' have a score of 13.

Input (Char Array, Char Array) Output (Double)
{L, a, i, l, a}, {M, a, j, n, u} L + i + l + a = 12 + 9 + 12 + 1 = 34
M + j + n + u = 13 + 10 + 14 + 21 = 58
Index = ( 34 / 58 ) * 100 = 58.62069
{R, o, m, e, o}, {J, u, l, i, e, t} R + o + m + o = 18 + 15 + 13 + 15 = 61
J + u + l + i + t = 10 + 21 + 12 + 9 + 20 = 72
Index = ( 61 / 72 ) * 100 = 84.72222
{N, a, g, a, r, j, u, n, a}, {A, m, a, l, a} N + g + r + j + u + n = 14 + 7 + 18 + 10 + 21 + 14 = 84
m + l = 13 + 12 = 25
Index = ( 25 / 84 ) * 100 = 29.7619

class FindLoveIndex

{    public static void main(String s[])
    {
        char person1[] = {'R', 'o', 'm', 'e', 'o'};
        char person2[] = {'J', 'u', 'l', 'i', 'e', 't'};
        System.out.println("The love index of Romeo and Juliet  : " + getLoveIndex(person1, person2));

    }


public static double getLoveIndex(char person1[], char person2[]) {
//Write a code here to calculate the love index of the persons and return it.
}
}


Doubts

Problems

Topic: Java Character Class

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App