Wednesday, January 11, 2017

Java Program : How to find the LOVE percentage calculator between a boy and a girl.

It is a Fun Love calculator  algorithm to find out love percentage. It is only for fun.

You can check FLAMES Game.



Here is Java program.


package swain.swain;

import java.util.ArrayList;
import java.util.List;

public class LoveCalculator {
private static List<String> getCount(String fname, String sname) {
List<String> list = new ArrayList<String>();
String love = "Love";
String name1 = fname;
String name2 = sname;
for (int i = 0; i < name1.length(); i++) {
String temp = name1.charAt(i) + "";

if (list.contains(temp)) {
int indexOfElement = list.indexOf(temp);
int prevCount = Integer.parseInt(list.get(++indexOfElement).toString());
prevCount++;
String newCount = (prevCount) + "";
list.set(indexOfElement, newCount);
continue;
}

list.add(temp);
list.add("1");
}

for (int i = 0; i < name2.length(); i++) {
String temp = name2.charAt(i) + "";

if (list.contains(temp)) {
int indexOfElement = list.indexOf(temp);
int prevCount = Integer.parseInt(list.get(++indexOfElement).toString());
prevCount++;
String newCount = (prevCount) + "";
list.set(indexOfElement, newCount);
continue;
}

list.add(temp);
list.add("1");
}

for (int i = 0; i < love.length(); i++) {
String temp = love.charAt(i) + "";

if (list.contains(temp)) {
int indexOfElement = list.indexOf(temp);
int prevCount = Integer.parseInt(list.get(++indexOfElement).toString());
prevCount++;
String newCount = (prevCount) + "";
list.set(indexOfElement, newCount);
continue;
}

list.add(temp);
list.add("1");
}
List<String> result = new ArrayList<String>();

for (int i = 1; i < list.size(); i += 2) {
result.add(list.get(i));
}
return result;
}

private static int getLovePercentage(String fname, String sname) {
List<String> count = getCount(fname, sname);
if (count.size() == 1) {
String result = count.get(0).toString() + "";
return Integer.parseInt(result);
}

if (count.size() == 2) {
String result = count.get(0).toString() + count.get(1).toString();
return Integer.parseInt(result);
}

do {
List<String> sub = new ArrayList<String>();
int size = count.size() / 2;
for (int i = 0; i < size; i++) {
String newC = (Integer.parseInt(count.get(i).toString()) + Integer.parseInt(count.get(count.size() - 1 - i).toString())) + "";

if (newC.length() == 2) {
sub.add((newC.charAt(0) + ""));
sub.add((newC.charAt(1) + ""));
} else {
sub.add(newC);
}
}

if ((size * 2) != count.size())
sub.add(count.get(size));

count = new ArrayList<String>();
count = sub;
} while (count.size() != 2);

String result = count.get(0).toString() + count.get(1).toString();
return Integer.parseInt(result);
}

public static String getLovePercentageResult(String fname, String sname) {
int per = getLovePercentage(fname, sname);
String result = "Love Percentage Between " + fname + " And " + sname + " is " + per + "% ";

return result;
}

public static void main(String args[]) {
System.out.println(LoveCalculator.getLovePercentageResult("Rama", "Sita"));
}
}


Output:


6 comments:

  1. I have express a few of the articles on your website now, and I really like your style of blogging. I added it to my favorite’s blog site list and will be checking back soon… online antiderivative calculator

    ReplyDelete
  2. Your post is providing good information. I liked it and enjoyed reading it. Keep sharing such important posts. I am very much pleased with the contents you have mentioned. I wanted to thank you for this great article. I enjoyed every little bit part of it and I will be waiting for the new updates. I really appreciated this post. Just want to say thank you for the information you have shared. Just continue writing this kind of post.
    how to get rid of hiccups

    ReplyDelete
  3. I have been using this app Amazon Shopping Apk : and downloaded and gambling it frequently.

    ReplyDelete
  4. This type of message always inspiring and I prefer to read quality content, so happy to find good place to many here in the post, the writing is just great, thanks for the post.
    in love quiz

    ReplyDelete
  5. What a fantabulous post this has been. Never seen this kind of useful post. buy YouTube Views cheap

    ReplyDelete
  6. I recently found much helpful information on your website, especially this blog page. best place to buy Instagram followers

    ReplyDelete

How ChatGPT can Benefit Coding: Your Guide to Leveraging an AI Language Model

 Introduction: Hello, coders! Welcome to this blog post on how ChatGPT, an AI language model, can benefit your coding skills and projects. A...