Showing posts with label Fun. Show all posts
Showing posts with label Fun. Show all posts

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:


Java Program : How to find the relation between a boy and a girl using FLAMES.

It is really a fun game. Below find out Java code for this game.


You can check LOVE Calculator  .


Here is program.


package swain.swain;

public class Flames {

public static String getMatchResult(String fname, String sname) {
String firstName, secondName;
if (fname != null & sname != null) {
firstName = fname.trim().toLowerCase();
secondName = sname.trim().toLowerCase();
String firstNames[] = firstName.split(" ");
String secondNames[] = secondName.split(" ");
firstName = "";
secondName = "";
for (int i = 0; i < firstNames.length; i++) {
firstName = firstName + firstNames[i];
}
for (int i = 0; i < secondNames.length; i++) {
secondName = secondName + secondNames[i];
}
int length = secondName.length() + secondName.length();
boolean namecheck[] = new boolean[secondName.length()];
for (int i = 0; i < secondName.length(); i++) {
namecheck[i] = false;
}
for (int i = 0; i < firstName.length(); i++) {
for (int j = 0; j < secondName.length(); j++) {
if ((namecheck[j] == false) && (firstName.charAt(i) == secondName.charAt(j))) {
namecheck[j] = true;
length = length - 2;
break;
}
}
}
boolean flamescheck[] = new boolean[6];
for (int i = 0; i < 6; i++) {
flamescheck[i] = true;
}
int count = 6;
int k = 1, deleted_letters = 0;
int j;
for (j = 0; j <= count; j++) {
if (k <= length) {
if (j == count) {
j = 0;
}
if (flamescheck[j] == true) {
k = k + 1;
}
}
if ((k - 1) == length) {
deleted_letters = deleted_letters + 1;
flamescheck[j] = false;
k = 1;
}
if (deleted_letters == 6) {
if (j == 0) {
return firstName.toUpperCase() + " and " + secondName.toUpperCase() + " are good FRIENDS";
} else if (j == 1) {
return firstName.toUpperCase() + " and " + secondName.toUpperCase() + " are LOVERS";
} else if (j == 2) {
return firstName.toUpperCase() + " and " + secondName.toUpperCase() + " have alot of AFFECTION";
} else if (j == 3) {
return firstName.toUpperCase() + " and " + secondName.toUpperCase() + " are MARRIED";
} else if (j == 4) {
return firstName.toUpperCase() + " and " + secondName.toUpperCase() + " are ENEMIES";
} else if (j == 5) {
return firstName.toUpperCase() + " and " + secondName.toUpperCase() + " are SIBLINGS";
}
break;
}
}
}
return null;
}

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

Output:

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...