1.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS11
* Problem: 11878 - Homework Checker
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=226&page=show_problem&problem=3000
*
* @author Christian Posselt
* @author Christian Mitterreiter
* @version 1.0, 23.03.2011
*
* Status: Accepted
* Time: 0.144
*/

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));
int correct = 0;

do
{
//if the mathematics of this line is correct, increase number of correctness
if(check(reader.readLine()))
correct ++;
}
while(reader.ready());

System.out.println(correct);

}

public static boolean check(String homework)
{
int a,b,sum;
int indexStart, indexEnd;
boolean add;

//Addition or Subtraction?
add = homework.indexOf("+")>=0;

try
{
//get first number
indexStart = 0;
if(add)
indexEnd = homework.indexOf("+");
else
indexEnd = homework.indexOf("-");

//parse first number
a = Integer.parseInt(homework.substring(indexStart, indexEnd));

//get second number
indexStart = indexEnd + 1;
indexEnd = homework.indexOf("=");

//parse second number
b = Integer.parseInt(homework.substring(indexStart, indexEnd));

//parse sum
sum = Integer.parseInt(homework.substring(indexEnd + 1, homework.length()));
}
//if Exception occurs, e.g. number format exception, homework is wrong
catch(Exception e)
{
return false;
}

return correct(a,add,b,sum);
}

/**
* correct
*
* Checks if a calculation of the form a +/- b = c is correct.
*
* @param a: int of parameter a
* @param add: boolean: true = addition, false = subtraction
* @param b: int of parameter b
* @param sum: int of sum
* @return boolean: calculation is correct or false
*/
public static boolean correct (int a, boolean add, int b, int sum)
{
//Addition or Subtraction?
if(add)
if(a+b == sum)
return true;
else
return false;

else
if(a-b == sum)
return true;
else
return false;

}

}


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

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();
}
}