To download code/application click the following link 99applications.com/java_programs and you can also find many c and c plus plus common programs in C & C++ section
Visit http://freesourcecode.blogspot.com for Thambola, Housie, Love Calculator, Friendship Calculator, FLAMES, Animations, Digital Number, Sudoku.java - Java Programmes.
Welcome to this great invention of Doctor Love!
We all know that a name can tell a lot about a person. Names are not randomly chosen: they all have a meaning.
Doctor Love knew this so he made another great invention just for the lonely you!
Sometimes you'd like to know if a relationship with someone could work out. Therefore Doctor Love himself designed this great machine for you. With The Love Calculator you can calculate the probability of a successful relationship between two people. The Love Calculator is an affective way to get an impression of what the chances are on a relationship between two people.
This is just a fun application. Dont take it seriously.
Note: This is a funny logic in this testing if this example has caused any problems, please excuse me its only meant for fun!
/**************************************************************************/
Java Program - Love Calculator
Author@ Krishnakanth Soni
Feedback@ sonikrishnakanth@gmail.com
Usage: java Love rama sita
/**************************************************************************/
Java Program - Love Calculator
Author@ Krishnakanth Soni
Feedback@ sonikrishnakanth@gmail.com
Usage: java Love rama sita
/**************************************************************************/
import java.util.*;
class Love
{
private String name1;
private String name2;
public void setFirstName( String name1 ){
this.name1 = name1.toUpperCase();
}
public void setSecondName( String name2 ){
this.name2 = name2.toUpperCase();
}
public void setNames( String name1, String name2 ){
this.name1 = name1.toUpperCase();
this.name2 = name2.toUpperCase();
}
private Vector getCount(){
Vector list = new Vector();
String love = "LOVE";
String name1 = this.name1;
String name2 = this.name2;
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" );
}
Vector result = new Vector();
for( int i=1; i<list.size(); i+=2 ){
result.add( list.get(i) );
}
//System.out.println( result );
return result;
}
public int getLovePer(){
Vector count = getCount();
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{
Vector sub = new Vector();
int size = count.size() / 2;
//System.out.println( 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 Vector();
count = sub;
//System.out.println( count );
}while( count.size() != 2 );
String result = count.get(0).toString() + count.get(1).toString();
return Integer.parseInt(result);
}
public int getLovePer( String name1, String name2 ){
String temp1 = this.name1;
String temp2 = this.name2;
setNames( name1, name2 );
int lPercentage = getLovePer();
setNames( temp1, temp2 );
return lPercentage;
}
public String toString(){
String result = "[ Love Percentage Between " + this.name1 + " And " + this.name2 + " is " + getLovePer() + "% ]";
return result;
}
public static void main(String[] args)
{
//System.out.println("Hello World!");
Love love = new Love();
if( args.length == 2 ){
love.setNames( args[0], args[1] );
System.out.println( "\n" + love + "\n" );
System.exit(0);
}else{
System.out.println( "\nUse With Proper usage, Find a sample FREINDSHIP Below\n java FriendShip name1 name2 \n" );
}
love.setNames( "krishna", "radha" );
System.out.println( "\n" + love + "\n" );
}
}
class Love
{
private String name1;
private String name2;
public void setFirstName( String name1 ){
this.name1 = name1.toUpperCase();
}
public void setSecondName( String name2 ){
this.name2 = name2.toUpperCase();
}
public void setNames( String name1, String name2 ){
this.name1 = name1.toUpperCase();
this.name2 = name2.toUpperCase();
}
private Vector getCount(){
Vector list = new Vector();
String love = "LOVE";
String name1 = this.name1;
String name2 = this.name2;
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" );
}
Vector result = new Vector();
for( int i=1; i<list.size(); i+=2 ){
result.add( list.get(i) );
}
//System.out.println( result );
return result;
}
public int getLovePer(){
Vector count = getCount();
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{
Vector sub = new Vector();
int size = count.size() / 2;
//System.out.println( 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 Vector();
count = sub;
//System.out.println( count );
}while( count.size() != 2 );
String result = count.get(0).toString() + count.get(1).toString();
return Integer.parseInt(result);
}
public int getLovePer( String name1, String name2 ){
String temp1 = this.name1;
String temp2 = this.name2;
setNames( name1, name2 );
int lPercentage = getLovePer();
setNames( temp1, temp2 );
return lPercentage;
}
public String toString(){
String result = "[ Love Percentage Between " + this.name1 + " And " + this.name2 + " is " + getLovePer() + "% ]";
return result;
}
public static void main(String[] args)
{
//System.out.println("Hello World!");
Love love = new Love();
if( args.length == 2 ){
love.setNames( args[0], args[1] );
System.out.println( "\n" + love + "\n" );
System.exit(0);
}else{
System.out.println( "\nUse With Proper usage, Find a sample FREINDSHIP Below\n java FriendShip name1 name2 \n" );
}
love.setNames( "krishna", "radha" );
System.out.println( "\n" + love + "\n" );
}
}
No comments:
Post a Comment