1.

/**
* Angewandte Mathematik, SS11
* Problem: 11878 - Homework Checker
* http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=226&page=show_problem&problem=3000
* @author Sebastian Stumpf
* @author Benjamin Vogt
* @version 1.0, 2011-04-17 19:55:07
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.104
*/

import java.io.*;

public class Main
{
public static boolean checkAnswer(String answer)
{
if(answer.contains("?"))
return false;
answer = answer.replaceAll("[\\s]", "");
// split answer in stringArray with the numbers
String[] numbers = answer.split("[^0-9]");
// check if equation is true
if(answer.contains("+"))
return Integer.parseInt(numbers[0]) + Integer.parseInt(numbers[1]) == Integer.parseInt(numbers[2]);
else
return Integer.parseInt(numbers[0]) - Integer.parseInt(numbers[1]) == Integer.parseInt(numbers[2]);
}

public static void main(String[] args)
{
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
int count = 0;

try
{
do
{
String toCheck = input.readLine();
if(checkAnswer(toCheck))
++count;
}
while(input.ready());
System.out.println(count);
}
catch (Exception e)
{
}
}
}


-------------------------------
1.
/*
* ACM Contest training
* Problem: 11878 - Homework Checker
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=226&page=show_problem&problem=3000
*
* @author Christoph Goettschkes
* @version 1.0, 11/08/2010
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.124
*/

import java.io.*;

class Main
{
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int counter = 0;

do
{
String line = reader.readLine().trim();

line = line.replaceAll("\\s", "");

if (line.indexOf('?') < 0)
{

int sign = line.indexOf('-');
char signChar = '-';
if (sign == -1) {
sign = line.indexOf('+');
signChar = '+';
}

int equ = line.indexOf('=');

int c = Integer.parseInt(line.substring(equ+1));

int a = Integer.parseInt(line.substring(0, sign));
int b = Integer.parseInt(line.substring(sign+1, equ));

int calcC = (signChar == '+') ? a + b : a - b;

if (calcC == c)
counter++;
}
} while(reader.ready());
System.out.println(counter);
reader.close();
}
}