Menu
Question Index
...


Write a program to calculate the friendship strength using date of births of two persons. Strength is calculated by summing up 152 times the date difference and the reminder when the year difference is divided by -107. This sum is then divided by seven times the month difference. Then the reminder of this number when divided by hundred is considered as the strength. Please see the requirements below for better understanding.
If the strength is greater than 90 is "Special Friend to you",
if greater than 70 then "Both are Best Friends",
if greater than 35 then "Both are Good Friends",
if greater than 10 then "Friendship strength is Poor",
otherwise it is "Acquaintance"

Input (String, String) Output (String)
"6-Nov-1990", "1-Oct-1990" VALUE = (((6 - 1) * 152) + ((1990 - 1990) % (-107))) / ((11 - 10) * 7) = 108
STRENGTH = VALUE % 100 = 108 % 100 = 8
Acquaintance
"29-Mar-1996", "19-Dec-2012" VALUE = (((29 - 19) * 152) + ((1996 - 2012) % (-107))) / ((3 - 12) * 7) = -23
STRENGTH = VALUE % 100 = -23 % 100 = -23 = 23
Friendship strength is Poor
"9-Jul-1991", "19-Jan-1995" VALUE = (((9 - 19) * 152) + ((1991 - 1995) % (-107))) / ((7 - 1) * 7) = -36
STRENGTH = VALUE % 100 = -36 % 100 = -36 = 36
Both are Good Friends
"21-Dec-1989", "28-Oct-1985" VALUE = (((21 - 28) * 152) + ((1989 - 1985) % (-107))) / ((12 - 10) * 7) = -75
STRENGTH = VALUE % 100 = -75 % 100 = -75 = 75
Both are Best Friends
"9-Nov-1979", "18-Sep-1979" VALUE = (((9 - 18) * 152) + ((1979 - 1975) % (-107))) / ((11 - 9) * 7) = -97
STRENGTH = VALUE % 100 = -97 % 100 = -97 = 97
Special Friend to you

class FriendshipStrength

{    public static void main(String s[])
    {
        String myDOB = "9-Nov-1979";
        String friendDOB = "18-Sep-1979";
        System.out.println(findFriendshipStrength(myDOB, friendDOB));

    }


public static String findFriendshipStrength(String myDOB, String friendDOB) {
//Write a code here calculate the friendship strength
}
}

Doubts

Problems

Topic: Locale Class In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App