Pagini recente » Cod sursa (job #1003173) | Cod sursa (job #1842059) | tema | Cod sursa (job #1332173) | Cod sursa (job #2447920)
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("file.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)) {
c = limit;
}
FileWriter out = new FileWriter(new File("file.out"));
out.append(c.toString());
out.close();
}
}