Menu
Question Index
...


Write a program find the luck percentage of a person on a given date. For finding the luck percentage, add the ascii codes of all the letters (ignore spaces and treat small letters and capitals as they are) in the name. To that sum add 13 times the difference of the birth date and current date. From that sum subtract 11 times the difference of the birth month and the current month. To that sum add 7 times the difference in birth year and current year. And finally divide the sum by 100 and the remainder will be the luck percentage.

Input (String, String, String) Output (Double)
"Kiran Kumar", "6-Nov-1990", "10-Sep-2010" SUM = K + i + r + a + n + K + u + m + a + r
= (75 + 105 + 114 + 97 + 110 + 75 + 117 + 109 + 97 + 114) + ((6 - 10) * 13) + ((11 - 9) * (-11)) + ((1990 - 2010) * 7)
= 1013 + (-214)
= 799
LUCK = SUM % 100 = 799 % 100 = 99
"Samantha Ruth Prabhu", "28-Apr-1987", "15-Sep-2013" SUM = S + a + m + a + n + t + h + a + R + u + t + h + P + r + a + b + h + u
= (83 + 97 + 109 + 97 + 110 + 116 + 104 + 97 + 82 + 117 + 116 + 104 + 80 + 114 + 97 + 98 + 104 + 117) + ((28 - 15) * 13) + ((4 - 9) * (-11)) +((1987 - 2013) * 7)
= 1842 + 42
= 1884
LUCK = SUM % 100 = 1884 % 100 = 84
"Ashok Kumar", "09-Jul-1991", "15-Jan-2013" SUM = A + s + h + o + k + K + u + m + a + r
= (65 + 115 + 104 + 111 + 107 + 75 + 117 + 109 + 97 + 114) + ((9 - 15) * 13) + ((7 - 1) * (-11)) +((1991 - 2013) * 7)
= 1014 + (-298)
= 716
LUCK = SUM % 100 = 716 % 100 = 16
"Tamannaah", "21-Dec-1989", "25-Jan-2009" SUM = T + a + m + a + n + n + a + a + h
= (84 + 97 + 109 + 97 + 110 + 110 + 97 + 97 + 104) + ((21 - 25) * 13) + ((12 - 1) * (-11)) +((1989 - 2009) * 7)
= 905 + (-313)
= 592
LUCK = SUM % 100 = 592 % 100 = 92

class FindLuckPercentage

{    public static void main(String s[])
    {
        String nameOfThePerson = "Kiran Kumar";
        String dateOfBirth = "06-Nov-1990";
        String currentDate = "10-Sep-2010";
        System.out.println(nameOfThePerson + "'s luck percentage on " + currentDate + " is : " + getLuckPercent(nameOfThePerson, dateOfBirth, currentDate));

    }


public static double getLuckPercent(String name, String dobString, String currentDateString) {
//Write a code here to the luck percentage of a person on a given date
}
}

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