1.
import java.util.Scanner;


/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS11
* Problem: 10424 Love Calculator
* Link:
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=16&page=show_problem&problem=1365
*
* @author Rolf Schirm
* @version 1.1, 03/23/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.116
*/
public class Main {
public static void main(String... args) {
Scanner scan = new Scanner(System.in);

while(scan.hasNextLine()) {
String firstName = scan.nextLine();
String secondName = scan.nextLine();

int firstNumber = calcNumber(firstName);
int secondNumber = calcNumber(secondName);

if(firstNumber == secondNumber) {
System.out.println("100.00 %");
} else if(firstNumber < secondNumber) {
System.out.printf("%.2f %%\n", (((double)firstNumber)/secondNumber)*100);
} else {
System.out.printf("%.2f %%\n", (((double)secondNumber)/firstNumber)*100);
}
}
}

private static int calcNumber(String name) {
int number = 0;

for(int i = 0; i < name.length(); i++) {
char c = name.charAt(i);
if(c >= 'a' && c <= 'z') {
number += c - 'a' + 1;
} else if(c >= 'A' && c <= 'Z') {
number += c - 'A' + 1;
}
}

while(number > 9) {
int temp = 0;
while(number > 0) {
temp += number % 10;
number /= 10;
}
number = temp;
}

return number;
}
}


2.

import java.util.Scanner;

/** Marion Gödel 10424 0.116
*
* @author ifw07248
*
*/

public class Main {

public static void main(String[] args){

Scanner scan = new Scanner(System.in);

while(scan.hasNext()){
char[] in1 = null, in2 = null;

String tmpS = scan.nextLine();
in1 = tmpS.toCharArray();

tmpS = scan.nextLine();
in2 = tmpS.toCharArray();

int sum1, sum2;
double result = -1;

if(in1 != null && in2 != null){
sum1 = calcSum(in1);
sum2 = calcSum(in2);

sum1 = oneDigit(sum1);
sum2 = oneDigit(sum2);

result = (double) min(sum1,sum2) / (double) max(sum1,sum2) * 100;

}
System.out.printf("%.2f %%\n", result);

}

}

private static int min(int a, int b){
if(a < b)
return a;
return b;
}

private static int max(int a, int b){
if(a > b)
return a;
return b;
}

private static int calcSum(char[] in){

int sum = 0;

for(int i = 0; i < in.length; i ++){
int tmp = (int) in[i];

if(tmp >= 'A' && tmp <= 'Z') {
sum+= tmp-64;
}
else if(tmp >= 'a' && tmp <= 'z'){
sum += tmp - 96;
}
}

return sum;
}


private static int oneDigit(int sum){

int sumCpy, oneDig;

while(sum > 9){

sumCpy = sum;
oneDig = 0;

while(sumCpy > 9){ // mehrstellig
int tmp = sumCpy % 10; // rest
sumCpy = sumCpy / 10;
oneDig += tmp;
}
oneDig += sumCpy;
sum = oneDig;

}

return sum;

}

}

// You will be given two names. These two names can have white space or
// some other non-alphabetical characters like $ @ & % etc.
// But only the alphabets from a to z or A to Z will participate in love calculation.
// Each alphabet has a particular value. The values are from 1 to 26 in ascending order
// of the alphabets. Its like this, a = 1, b = 2, c = 3........ z = 26.
// Both upper case and lower case holds the same values.
// Then make the sum of these numbers until it comes in one digit.[
// For example, consider a name 'bcz'. Here, b = 2, c = 3 & z = 26.
// So, the sum is (2+3+26) = 31 = (3+1) = 4.] Then the ratio of these two numbers in percentage will be the result.


3.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS11
* Problem: 10424 Love Calculator
* Link: http://bbs.cooldavid.org/acm/v104/10424.html
*
* @author Beinhofer Christian
* @version 1.0, 23.03.2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.040
*/

#include <stdio.h>
#include <ctype.h>

int CalculateValue(char name[25])
{
char c;
int result = 0;
int value = 0;

for(int i = 0; name[i] != '\0'; i++)
{
c = tolower(name[i]);

if(c >= 'a' && c <= 'z')
{
value += c - 'a' + 1;
}
}

result = value;
while(result > 9)
{
value = result;
result = 0;
while(value != 0)
{
result += value % 10;
value /= 10;
}
}

return result;
}

int main(int argc, char* argv[])
{
char name1[26];
char name2[26];

while(true)
{
if(!gets(name1)) return 0;
gets(name2);

int value1 = CalculateValue(name1);
int value2 = CalculateValue(name2);

double love;
if(value1 < value2)
love = ((double)value1 * 100) / (double)value2;
else
love = ((double)value2 * 100) / (double)value1;

if(love > 100) love = 100;

printf("%.2f %%\n", love);
}
}



4.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS11
* Problem: 10424 - Love Calculator
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=16&page=show_problem&problem=1365
* @author Mitterreiter Christian
* @author Posselt Christian
* @version 1.0, 03/23/2011
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.104
*/

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

/**
* Berechnet die Quersumme der Zahl sum. So lange die errechnete Quersumme grö�er 9 ist,
* wird ernet die Quersumme berechnet.
* @param sum
* @return
*/
public static int qSum(int sum) {
int qsum = 0;
while (sum > 0) {
qsum += sum % 10;
sum = sum / 10;
}
if (qsum > 9) {
return qSum(qsum);
}
return qsum;
}

public static void main(String[] args) throws IOException {

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
/** Name der ersten Person */
String name1 = "";

/** Name der zweiten Person */
String name2 = "";

/** Summe der einzelnen Buchstabenwerte */
int sum1 = 0;
int sum2 = 0;

/** Quersumme*/
double qsum1 = 0;
double qsum2 = 0;

/** Ergebniss einer Auswertung */
double result = 0;

do {

sum1 = 0;
sum2 = 0;
qsum1 = 0;
qsum2 = 0;
result = 0;

//Beide Namen einlesen
name1 = br.readLine().toLowerCase();
name2 = br.readLine().toLowerCase();

//Summe der einzelnen Buchstabenwerte für den ersten Namen
for (int i = 0; i < name1.length(); i++) {
char c = name1.charAt(i);
if (c >= 'a' && c <= 'z') {
sum1 += c - 96;
}
}

qsum1 = qSum(sum1);

//Summe der einzelnen Buchstabenwerte für den zweiten Namen
for (int i = 0; i < name2.length(); i++) {
char c = name2.charAt(i);
if (c >= 'a' && c <= 'z') {
sum2 += c - 96;
}
}

qsum2 = qSum(sum2);

if (qsum1 > qsum2) {
result = qsum2 / qsum1;
} else {
result = qsum1 / qsum2;
}

result *= 100;

System.out.printf("%.2f %%%n", result);

} while (br.ready());

}

}

5.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS11
* Problem: 10424 Love Calculator
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=23&page=show_problem&problem=2113
*
* @author Burgmair Stefan
* @version 1.0, 04/23/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.108
*/

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
public static void main(String[] args) throws IOException
{


BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

do
{
String firstName = reader.readLine();
String secondName = reader.readLine();

double ergebnis = Math.min(valueOfString(firstName), valueOfString(secondName)) * 1.0 / Math.max(valueOfString(firstName), valueOfString(secondName)) * 100;

System.out.printf("%.2f %%\n", ergebnis);
} while(reader.ready());


}

public static double valueOfString(String name)
{
name = name.toLowerCase();
int o;
int value = 0;
for (int i = 0; i < name.length(); i ++)
{
o = (int)(name.charAt(i));
if ((o >= 97) && (o < 123))
{
value += o - 96;
}

}
return reduceValue(value);

}

public static int reduceValue(int value)
{
while (value > 9)
{
int s = 0;
while (value > 0)
{
s += value %10;
value /= 10;
}
value = s;
}
return value;
}

//You will be given two names. These two names can have white space or some other non-alphabetical characters
//like $ @ & % etc. But only the alphabets from a to z or A to Z will participate in love calculation.
//Each alphabet has a particular value. The values are from 1 to 26 in ascending order of the alphabets.
//Its like this, a = 1, b = 2, c = 3........ z = 26. Both upper case and lower case holds the same values.
//Then make the sum of these numbers until it comes in one digit.[ For example, consider a name 'bcz'.
//Here, b = 2, c = 3 & z = 26. So, the sum is (2+3+26) = 31 = (3+1) = 4.] Then the ratio of these two numbers
//in percentage will be the result.
}

6.


/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS11
* Problem: 10424 Love Calculator
* Link: http://bbs.cooldavid.org/acm/v104/10424.html
*
* @author Weigl Joseph
* @author Müller Thomas
* @version 1.0, 03/30/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.116
*/

import java.util.Scanner;

public class Main {

private final static int diff = 96;


private static char[] onlyLetters(char[] cArray){
for(int i = 0; i < cArray.length; i++)
if(!Character.isLetter(cArray[i]))
cArray[i] = 0;
return cArray;
}

private static int generateSum(char[] cArray){
int sum = 0;
for(char c: cArray){
if((int) c > diff)
sum = sum + (c-diff);
}
return sum;
}

private static int generateChecksum(int sum){
while((sum/10)>= 1){
sum = (sum/10)+(sum%10);
}
return sum;

}

public static void main(String... args){

int firstSum,
secondSum;

double solution;

Scanner in = new Scanner(System.in);

do{
char[] firstName = in.nextLine().toLowerCase().toCharArray(),
secondName = in.nextLine().toLowerCase().toCharArray();

firstName = onlyLetters(firstName);
secondName = onlyLetters(secondName);

firstSum = generateSum(firstName);
secondSum = generateSum(secondName);

firstSum = generateChecksum(firstSum);
secondSum = generateChecksum(secondSum);

//System.out.println(firstSum);
//System.out.println(secondSum);

if(firstSum <= secondSum)
solution = (double) firstSum / (double) secondSum;
else
solution = (double) secondSum / (double) firstSum;

solution *=100;
System.out.printf("%.2f %%%n",solution);



}while(in.hasNextLine());
}
}



--------------------------------------------------------------------------


1.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, WS10/11
* Problem: 10424 Love Calculator
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=16&page=show_problem&problem=1365
*
* @author Fabian Liebl
* @version 1.0, 10/06/2010
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.104
*/

import java.io.*;

public class Main {

private static int getValue(String s) {
int value = 0;
char c;
for (int i = 0; i < s.length(); i++) {
c = s.charAt(i);
if ((c >= 'a') && (c <= 'z'))
{
value += c - 96;
}
if ((c >= 'A') && (c <= 'Z')) {
value += c - 64;
}
}
return value;
}

private static int getCrossSum(int i) {
int x = i;
int value = 0;
while (x > 0) {
value += x % 10;
x = x / 10;
}
return value;
}

public static void main(String[] args) throws IOException {
BufferedReader inputReader = new BufferedReader(new InputStreamReader(System.in));

String name1, name2;
int name1Value, name2Value;
double love;

while (true) {
name1 = inputReader.readLine();
if (name1 == null) {
// EOF
return;
}
name2 = inputReader.readLine();

name1Value = getValue(name1);
name2Value = getValue(name2);

while (name1Value > 9) {
name1Value = getCrossSum(name1Value);
}
while (name2Value > 9) {
name2Value = getCrossSum(name2Value);
}

if (name1Value > name2Value) {
love = (double) name2Value / (double) name1Value;
} else {
love = (double) name1Value / (double) name2Value;
}

System.out.printf("%.2f %%\n", love*100);
}
}

}