Cod sursa(job #2186921)

Utilizator vianulegendsTudor Vianu vianulegends Data 26 martie 2018 08:46:40
Problema A+B Scor 0
Compilator java Status done
Runda Arhiva de probleme Marime 1.37 kb
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication1;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author elev
 */
public class adunare {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc= new Scanner("adunare.in");
        
        int a, b;
        try {
            if(!Files.exists(Paths.get("adunare.out")))     
            {
                Files.createFile(Paths.get("adunare.out"));
            }
            PrintWriter pw = new PrintWriter("adunare.out");
            a = sc.nextInt();
            b = sc.nextInt(); 
            pw.append(Integer.toString(a + b));
        } catch (FileNotFoundException ex) {
            System.out.println("Ba tarane nu ti-am gasit fisieru");
        } catch (IOException ex) {
            System.out.println("Cacat ca nu mere!");
        }                                
    }
    
}