Pagini recente » Cod sursa (job #3245471) | Cod sursa (job #1227905) | Cod sursa (job #1960506) | Cod sursa (job #948942) | Cod sursa (job #2447923)
import java.io.File;
import java.io.FileWriter;
import java.util.Scanner;
import java.io.FileNotFoundException;
import java.io.IOException;
/**
* Reads in numbers on file.in, one per line.
* Outputs a number to file.out, that is the sum of the two numbers in file.in.
* The number itself cannot be greater than 2,000,000, and if it is, return the limit
*/
public class Main {
Main() {
}
public static void main(String[] args) throws FileNotFoundException, IOException {
Scanner in = new Scanner(new File("adunare.in"));
Integer a = in.nextInt();
Integer b = in.nextInt();
in.close();
Integer limit = 2 * (int) Math.pow(10, 6);
Integer c = a + b;
if ((a >= limit) || (b >= limit) || (c >= limit)) {
System.exit(1);
}
FileWriter out = new FileWriter(new File("adunare.out"));
out.append(c.toString());
out.close();
System.exit(0);
}
}